Fix instance's image_ref lost on failed unshelving
Closes-Bug: #1934094 Signed-off-by: Pierre-Samuel Le Stang <pierre-samuel.le-stang@corp.ovh.com> Change-Id: Id908a7224ff3378b3b51726bbfa8b5805d38ca59
This commit is contained in:
@@ -6683,6 +6683,10 @@ class ComputeManager(manager.Manager):
|
||||
with excutils.save_and_reraise_exception(logger=LOG):
|
||||
LOG.exception('Instance failed to spawn',
|
||||
instance=instance)
|
||||
# Set the image_ref back to initial image_ref because instance
|
||||
# object might have been saved with image['id']
|
||||
# https://bugs.launchpad.net/nova/+bug/1934094
|
||||
instance.image_ref = shelved_image_ref
|
||||
# Cleanup allocations created by the scheduler on this host
|
||||
# since we failed to spawn the instance. We do this both if
|
||||
# the instance claim failed with ComputeResourcesUnavailable
|
||||
|
||||
@@ -684,8 +684,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
||||
https://bugs.launchpad.net/nova/+bug/1934094
|
||||
"""
|
||||
instance = self._create_fake_instance_obj()
|
||||
# TODO(pslestang) to uncomment when bug 1934094 is fixed
|
||||
# initial_image_ref = instance.image_ref
|
||||
initial_image_ref = instance.image_ref
|
||||
|
||||
fake_spec = objects.RequestSpec()
|
||||
shelved_image = {'id': uuids.image_id}
|
||||
@@ -696,10 +695,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
||||
self.compute.unshelve_instance, self.context, instance,
|
||||
image=shelved_image, filter_properties={},
|
||||
node='fake-node', request_spec=fake_spec, accel_uuids=[])
|
||||
# FIXME(pslestang) Until bug 1934094 is fixed
|
||||
# The instance.image_ref is set to shelved_image.id but should be
|
||||
# equal to initial_image_ref
|
||||
self.assertEqual(instance.image_ref, shelved_image['id'])
|
||||
self.assertEqual(instance.image_ref, initial_image_ref)
|
||||
|
||||
@mock.patch.object(objects.InstanceList, 'get_by_filters')
|
||||
def test_shelved_poll_none_offloaded(self, mock_get_by_filters):
|
||||
|
||||
Reference in New Issue
Block a user