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):
|
with excutils.save_and_reraise_exception(logger=LOG):
|
||||||
LOG.exception('Instance failed to spawn',
|
LOG.exception('Instance failed to spawn',
|
||||||
instance=instance)
|
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
|
# Cleanup allocations created by the scheduler on this host
|
||||||
# since we failed to spawn the instance. We do this both if
|
# since we failed to spawn the instance. We do this both if
|
||||||
# the instance claim failed with ComputeResourcesUnavailable
|
# the instance claim failed with ComputeResourcesUnavailable
|
||||||
|
|||||||
@@ -684,8 +684,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
|||||||
https://bugs.launchpad.net/nova/+bug/1934094
|
https://bugs.launchpad.net/nova/+bug/1934094
|
||||||
"""
|
"""
|
||||||
instance = self._create_fake_instance_obj()
|
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()
|
fake_spec = objects.RequestSpec()
|
||||||
shelved_image = {'id': uuids.image_id}
|
shelved_image = {'id': uuids.image_id}
|
||||||
@@ -696,10 +695,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
|||||||
self.compute.unshelve_instance, self.context, instance,
|
self.compute.unshelve_instance, self.context, instance,
|
||||||
image=shelved_image, filter_properties={},
|
image=shelved_image, filter_properties={},
|
||||||
node='fake-node', request_spec=fake_spec, accel_uuids=[])
|
node='fake-node', request_spec=fake_spec, accel_uuids=[])
|
||||||
# FIXME(pslestang) Until bug 1934094 is fixed
|
self.assertEqual(instance.image_ref, initial_image_ref)
|
||||||
# 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'])
|
|
||||||
|
|
||||||
@mock.patch.object(objects.InstanceList, 'get_by_filters')
|
@mock.patch.object(objects.InstanceList, 'get_by_filters')
|
||||||
def test_shelved_poll_none_offloaded(self, mock_get_by_filters):
|
def test_shelved_poll_none_offloaded(self, mock_get_by_filters):
|
||||||
|
|||||||
Reference in New Issue
Block a user