Skip to content

Commit 7068d9b

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Drop source node allocations if finish_resize fails" into stable/stein
2 parents ed24dfa + e6c6178 commit 7068d9b

File tree

3 files changed

+28
-17
lines changed

3 files changed

+28
-17
lines changed

nova/compute/manager.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4791,7 +4791,22 @@ def finish_resize(self, context, disk_info, image, instance,
47914791
migration)
47924792
except Exception:
47934793
with excutils.save_and_reraise_exception():
4794-
self._revert_allocation(context, instance, migration)
4794+
# At this point, resize_instance (which runs on the source) has
4795+
# already updated the instance host/node values to point to
4796+
# this (the dest) compute, so we need to leave the allocations
4797+
# against the dest node resource provider intact and drop the
4798+
# allocations against the source node resource provider. If the
4799+
# user tries to recover the server by hard rebooting it, it
4800+
# will happen on this host so that's where the allocations
4801+
# should go. Note that this is the same method called from
4802+
# confirm_resize to cleanup the source node allocations held
4803+
# by the migration record.
4804+
LOG.info('Deleting allocations for old flavor on source node '
4805+
'%s after finish_resize failure. You may be able to '
4806+
'recover the instance by hard rebooting it.',
4807+
migration.source_compute, instance=instance)
4808+
self._delete_allocation_after_move(
4809+
context, instance, migration)
47954810

47964811
def _finish_resize_helper(self, context, disk_info, image, instance,
47974812
migration):

nova/tests/functional/regressions/test_bug_1825537.py

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,16 +67,9 @@ def test_finish_resize_fails_allocation_cleanup(self):
6767
# allocations should still exist with the new flavor.
6868
source_rp_uuid = self._get_provider_uuid_by_host('host1')
6969
dest_rp_uuid = self._get_provider_uuid_by_host('host2')
70-
# FIXME(mriedem): This is bug 1825537 where the allocations are
71-
# reverted when finish_resize fails so the dest node resource provider
72-
# does not have any allocations and the instance allocations are for
73-
# the old flavor on the source node resource provider even though the
74-
# instance is not running on the source host nor pointed at the source
75-
# host in the DB.
76-
# self.assertFlavorMatchesAllocation(
77-
# self.flavor2, server['id'], dest_rp_uuid)
78-
dest_rp_usages = self._get_provider_usages(dest_rp_uuid)
79-
no_usage = {'VCPU': 0, 'MEMORY_MB': 0, 'DISK_GB': 0}
80-
self.assertEqual(no_usage, dest_rp_usages)
8170
self.assertFlavorMatchesAllocation(
82-
self.flavor1, server['id'], source_rp_uuid)
71+
self.flavor2, server['id'], dest_rp_uuid)
72+
# And the source node provider should not have any usage.
73+
source_rp_usages = self._get_provider_usages(source_rp_uuid)
74+
no_usage = {'VCPU': 0, 'MEMORY_MB': 0, 'DISK_GB': 0}
75+
self.assertEqual(no_usage, source_rp_usages)

nova/tests/functional/test_servers.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3723,10 +3723,13 @@ def fake_resize_method(*args, **kwargs):
37233723

37243724
# Ensure the allocation records still exist on the host.
37253725
source_rp_uuid = self._get_provider_uuid_by_host(hostname)
3726-
# FIXME(mriedem): This is wrong for the _finish_resize case.
3727-
# The new_flavor should have been subtracted from the doubled
3728-
# allocation which just leaves us with the original flavor.
3729-
self.assertFlavorMatchesUsage(source_rp_uuid, self.flavor1)
3726+
if failing_method == '_finish_resize':
3727+
# finish_resize will drop the old flavor allocations.
3728+
self.assertFlavorMatchesUsage(source_rp_uuid, self.flavor2)
3729+
else:
3730+
# The new_flavor should have been subtracted from the doubled
3731+
# allocation which just leaves us with the original flavor.
3732+
self.assertFlavorMatchesUsage(source_rp_uuid, self.flavor1)
37303733

37313734
def test_resize_to_same_host_prep_resize_fails(self):
37323735
self._test_resize_to_same_host_instance_fails(

0 commit comments

Comments
 (0)