nova allows to resize from a flavor with disk_size=0 defined

Bug #1305860 reported by Xavier Queralt
10
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Low
Liyingjun

Bug Description

For some reason nova allows creating a flavor with a disk_size of 0, when an instance is booted using such flavor its disk will use the native base image size as the size of the ephemeral root volume (from the ops docs).

Even though having the disk_size=0 means that the instance's disk can have any imaginable size, nova will still allow to resize that instance to any flavor defining disk_size >= 0 but it won't shrink the disk if it is bigger than the new disk_size.

Take for example the following:
 * we've an image of 2GB in glance
 * we boot an instance using this image and a flavor1 (with disk_size=0)
   -> The instance's disk will be of 2GB (same as image)
 * Afterwards, we resize this instance to flavor2 (with disk_size=1GB) which is allowed b/c new_disk_size > old_disk_size
 * The new instance will be using flavor2 according to the papers, but its ephemeral disk will still be 2GB (nova won't try to shrink the image)

A couple of solutions are possible here, either nova forbids to resize from any flavor with a disk_size=0 or nova checks the *real* size of the disk before even trying to resize, failing if it is bigger than the one defined by the new flavor. The drastic solution would be to forbid defining flavors with a disk_size=0, but I guess it wouldn't be possible to keep backwards compatibility.

Tags: compute
Revision history for this message
John Garbutt (johngarbutt) wrote :

No resize to/from zero disk flavor is probably my preference. Its kinda confusing when zero = any.

I think the XenAPI driver will check the actual disk size, but that still leaves things very confusing in some cases.

Tracy Jones (tjones-i)
tags: added: compute
Tiago Mello (timello)
Changed in nova:
importance: Undecided → Low
status: New → Confirmed
Liyingjun (liyingjun)
Changed in nova:
assignee: nobody → Liyingjun (liyingjun)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.openstack.org/98680

Changed in nova:
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/98680
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=a15ff712c3c9076b683a9d1d7cbd4e462943f4e1
Submitter: Jenkins
Branch: master

commit a15ff712c3c9076b683a9d1d7cbd4e462943f4e1
Author: liyingjun <email address hidden>
Date: Wed Jun 4 17:55:03 2014 +0800

    Do not allow resize to zero disk flavor

    For some reason nova allows creating a flavor with a disk_size of 0,
    when an instance is booted using such flavor its disk will use the
    native base image size as the size of the ephemeral root volume (from
    the ops docs:
    http://docs.openstack.org/openstack-ops/content/flavors.html).

    Even though having the disk_size=0 means that the instance's disk can
    have any imaginable size, nova will still allow to resize that instance
    to any flavor defining disk_size >= 0 but it won't shrink the disk if it
    is bigger than the new disk_size.

    This patch add check to prevent resize to zero disk flavor except
    when both current and new disk are 0.

    DocImpact

    Change-Id: Iffc2f821cc51ccf555ea1e3d7589147375aeb56a
    Closes-bug: 1305860

Changed in nova:
status: In Progress → Fix Committed
Changed in nova:
milestone: none → juno-2
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: juno-2 → 2014.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.