Resize instance from large flavor to small flavor based on Hyperv driver, instance status is error and the phsical instance get destroyed

Bug #1163844 reported by GuoHui Liu
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Undecided
Alessandro Pilotti

Bug Description

Test script:
1.Use flavor2 to deploy instance.
2.When deployment success , resize it from flavor2 to flavor1.
3.Instance status display error.

Flavor1 information:
1 CPU
512M memory
0G disk

Flavor2 information:
1 CPU
2048M memory
20G disk

the root cause is, in current hyperv driver implementation, when to perform finish_migration operation, there is a check that the VHD can't be resize to a smaller size.
                if new_size < curr_size:
                    raise vmutils.HyperVException(_("Cannot resize a VHD to a "
                                                    "smaller size"))
but at this point, the old instance get already destroyed, so the data could be lost.

Tags: hyper-v
Revision history for this message
Michael Fork (mjfork) wrote :

Started thread on the mailing list: http://lists.openstack.org/pipermail/openstack-dev/2013-April/007478.html

The behavior when the disk shrinks is inconsistent across all the hypervisors.

libvirt: logs it cannot resize to smaller and just keeps the larger disk
xen: tries to copy contents to a smaller disk, fails if too large
hyperv: always errors out if new disk size is smaller
powervm: silently keeps the larger disk
vmware: (couldn't find where migration code handled resize)

The only mention in the API guide - http://docs.openstack.org/api/openstack-compute/2/content/Resize_Server-d1e3707.html - is "scaling the server up or down."

Since Hyper-V always fails on a smaller disk and it can lead to being unable to access a VM, I would propose the behavior from libvirt and powervm be adopted and that this be addressed in the Nova v3 API and explicitly fail if we cannot resize down.

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/27045

Changed in nova:
assignee: nobody → GuoHui LIu (guohliu)
status: New → In Progress
GuoHui Liu (guohliu)
Changed in nova:
assignee: GuoHui LIu (guohliu) → nobody
Changed in nova:
assignee: nobody → GuoHui LIu (guohliu)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

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

Changed in nova:
assignee: GuoHui LIu (guohliu) → Alessandro Pilotti (alexpilotti)
Revision history for this message
Alessandro Pilotti (alexpilotti) wrote :

The driver's migrate_disk_and_power_off method should be able to raise an exception in case the target instance flavor is not compatible with the current one, without resulting in an ERROR state for the instance.

As an alternative, an additional driver method could be added to verify the flavor compatibility before calling migrate_disk_and_power_off.

tags: added: hyper-v
removed: hyperv
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/28354
Committed: http://github.com/openstack/nova/commit/d50d69cbd807dfb67427b39e03fd4156479c1997
Submitter: Jenkins
Branch: master

commit d50d69cbd807dfb67427b39e03fd4156479c1997
Author: Alessandro Pilotti <email address hidden>
Date: Tue May 7 01:04:22 2013 +0300

    Adds instance root disk size checks during resize

    Fixes bug: #1163844

    The Hyper-V driver does not support disk resizes to a smaller size.
    This patch verifies the disk size compatibility before the migration
    starts in order to avoid data losses.

    Change-Id: Ie99bf8779d583e97b911c9a136cee1bca9a1ecdc

Changed in nova:
status: In Progress → Fix Committed
Revision history for this message
Alessandro Pilotti (alexpilotti) wrote :

As an additional note:

We are discussing to add "Soft Errors" support in Nova, meaning that the exception that we raise here will result in an instance action instead of an ERROR state.

The patch that has been recently committed can thus be considered as an interim step.

Revision history for this message
GuoHui Liu (guohliu) wrote :

Hi Alessandro, thanks for this information, it sounds great to me, let's keep this bug to tracking the next improvement. and if you have time please take a look of another hyperv issue, https://bugs.launchpad.net/nova/+bug/1177927, thanks.

Revision history for this message
Alessandro Pilotti (alexpilotti) wrote :

One additional note:

During a chat on #openstack-nova we discussed about adding soft errors in Nova, by leveraging the new nova actions.

This will allow us to raise a "soft exception" at the beginning of the resize operation (like it happens now), keeping the instance in ACTIVE state instead of ERROR.

Thierry Carrez (ttx)
Changed in nova:
milestone: none → havana-1
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: havana-1 → 2013.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.