Don't fail image create on failure of cleanup

The failure that caused us to run a cleanup delete is the thing we
actually care about reporting. If the cleanup has an error, shrug and
move on to reporting the creation error.

Change-Id: If3956188214b2f627b14e4d820cf27c3080fd4dd
This commit is contained in:
Monty Taylor 2016-10-19 15:08:00 -05:00
parent 49f1f191df
commit e545865f8f
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594

View File

@ -3026,9 +3026,14 @@ class OpenStackCloud(_normalize.Normalizer):
self.manager.submit_task(_tasks.ImageUpload(
image_id=image.id, image_data=image_data))
except Exception:
self.log.debug("Deleting failed upload of image %(image)s",
{'image': image['name']})
self.manager.submit_task(_tasks.ImageDelete(image_id=image.id))
self.log.debug("Deleting failed upload of image %s", name)
try:
self.manager.submit_task(_tasks.ImageDelete(image_id=image.id))
except Exception:
# We're just trying to clean up - if it doesn't work - shrug
self.log.debug(
"Failed deleting image after we failed uploading it.",
exc_info=True)
raise
return image
@ -3043,10 +3048,15 @@ class OpenStackCloud(_normalize.Normalizer):
self.manager.submit_task(_tasks.ImageUpdate(
image=image, data=image_data))
except Exception:
self.log.debug("Deleting failed upload of image %(image)s",
{'image': image['name']})
# Note argument is "image" here, "image_id" in V2
self.manager.submit_task(_tasks.ImageDelete(image=image.id))
self.log.debug("Deleting failed upload of image %s", name)
try:
# Note argument is "image" here, "image_id" in V2
self.manager.submit_task(_tasks.ImageDelete(image=image.id))
except Exception:
# We're just trying to clean up - if it doesn't work - shrug
self.log.debug(
"Failed deleting image after we failed uploading it.",
exc_info=True)
raise
return image