From 7eb7c4c89a4dcf18f34bd1004b700b45f3cc10f4 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Wed, 1 Apr 2015 11:17:31 -0400 Subject: [PATCH] Poll on the actual image showing up Turns out just polling on the task completion doesn't mean you actually have the image. You also need to poll on the image becoming a thing in glance. Change-Id: I910ac612e6af1f5888c1820a09ee79fab012bdae --- shade/__init__.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/shade/__init__.py b/shade/__init__.py index 94e00a2ee..4249cbecc 100644 --- a/shade/__init__.py +++ b/shade/__init__.py @@ -1027,20 +1027,30 @@ class OpenStackCloud(object): container=container, name=name), image_properties=dict(name=name)))) if wait: + image_id = None for count in _iterate_timeout( timeout, "Timeout waiting for the image to import."): try: - status = self.manager.submitTask( - _tasks.ImageTaskGet(task_id=glance_task.id)) + if image_id is None: + status = self.manager.submitTask( + _tasks.ImageTaskGet(task_id=glance_task.id)) except glanceclient.exc.HTTPServiceUnavailable: # Intermittent failure - catch and try again continue if status.status == 'success': + image_id = status.result['image_id'] self._reset_image_cache() + try: + image = self.get_image(image_id) + except glanceclient.exc.HTTPServiceUnavailable: + # Intermittent failure - catch and try again + continue + if image is None: + continue self.update_image_properties( - name_or_id=status.result['image_id'], + image=image, **image_properties) return self.get_image_dict(status.result['image_id']) if status.status == 'failure':