From e545865f8ff0ec4c9af239231ebba87e3e7592f0 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 19 Oct 2016 15:08:00 -0500 Subject: [PATCH] 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 --- shade/openstackcloud.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index 99aeabf5f..581e93b82 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -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