From e27516fa1cb754062663b26c0ba58cd60e471d5b Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 13 Oct 2016 17:13:45 -0500 Subject: [PATCH] Delete image if we timeout waiting for it to upload In other places where we have a timeout waiting for a resource creation, we delete the half-finished resource. Do the same here. Change-Id: I6503847a7cde39d3a624c6b0f9ffe9a6fa265a26 --- shade/openstackcloud.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/shade/openstackcloud.py b/shade/openstackcloud.py index f9dff4bed..21b5b30a1 100644 --- a/shade/openstackcloud.py +++ b/shade/openstackcloud.py @@ -3044,12 +3044,18 @@ class OpenStackCloud(_normalize.Normalizer): self._get_cache(None).invalidate() if not wait: return image - for count in _utils._iterate_timeout( - 60, - "Timeout waiting for the image to finish."): - image_obj = self.get_image(image.id) - if image_obj and image_obj.status not in ('queued', 'saving'): - return image_obj + try: + for count in _utils._iterate_timeout( + 60, + "Timeout waiting for the image to finish."): + image_obj = self.get_image(image.id) + if image_obj and image_obj.status not in ('queued', 'saving'): + return image_obj + except OpenStackCloudTimeout: + self.log.debug( + "Timeout waiting for image to become ready. Deleting.") + self.delete_image(image.id, wait=True) + raise def _upload_image_task( self, name, filename, container, current_image,