Created
April 24, 2014 07:45
-
-
Save sahid/11245381 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/nova/conductor/manager.py b/nova/conductor/manager.py | |
index db9ab2f..cabdb00 100644 | |
--- a/nova/conductor/manager.py | |
+++ b/nova/conductor/manager.py | |
@@ -797,11 +797,6 @@ class ComputeTaskManager(base.Base): | |
filter_properties=filter_properties, | |
legacy_bdm_in_spec=legacy_bdm) | |
- def _get_image(self, context, image_id): | |
- if not image_id: | |
- return None | |
- return self.image_service.show(context, image_id) | |
- | |
def _delete_image(self, context, image_id): | |
(image_service, image_id) = glance.get_remote_image_service(context, | |
image_id) | |
@@ -827,18 +822,27 @@ class ComputeTaskManager(base.Base): | |
if snapshot_id: | |
self._delete_image(context, snapshot_id) | |
elif instance.vm_state == vm_states.SHELVED_OFFLOADED: | |
- try: | |
- with compute_utils.EventReporter(context, self.db, | |
- 'get_image_info', instance.uuid): | |
- image = self._get_image(context, | |
- sys_meta['shelved_image_id']) | |
- except exception.ImageNotFound: | |
- with excutils.save_and_reraise_exception(): | |
- LOG.error(_('Unshelve attempted but vm_state not SHELVED ' | |
- 'or SHELVED_OFFLOADED'), instance=instance) | |
- instance.vm_state = vm_states.ERROR | |
- instance.save() | |
+ def raises_shelve_corrupted(instance, reason): | |
+ instance.vm_state = vm_states.ERROR | |
+ instance.save() | |
+ LOG.error(reason, instance) | |
+ raise exception.ShelvedInstanceCorrupted( | |
+ instance_id=instance.uuid, reason=reason) | |
+ | |
+ image_id = sys_meta.get('shelved_image_id') | |
+ if not image_id: | |
+ reason = _('Unshelve attempted but the property ' | |
+ 'shelved_image_id cannot be found.') | |
+ raises_shelve_corrupted(instance, reason) | |
+ with compute_utils.EventReporter( | |
+ context, self.db, 'get_image_info', instance.uuid): | |
+ try: | |
+ image = self.image_service.show(context, image_id) | |
+ except exception.ImageNotFound: | |
+ reason = _('Unshelve attempted but the image %s ' | |
+ 'cannot be found.', image_id) | |
+ raises_shelve_corrupted(instance, reason) | |
try: | |
with compute_utils.EventReporter(context, self.db, | |
'schedule_instances', |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment