Use retriable_status_codes in image upload

This is supported down at the keystoneauth layer. Use it.

Change-Id: I3dfdc885a1c7989eb17244242c816a0a55aaea4a
This commit is contained in:
Monty Taylor 2019-02-27 14:28:39 +00:00
parent 232553daf7
commit c2b75dc6ea
3 changed files with 9 additions and 26 deletions

View File

@ -1,6 +1,7 @@
{
"auth_type": "password",
"baremetal_status_code_retries": 5,
"image_status_code_retries": 5,
"disable_vendor_agent": {},
"interface": "public",
"floating_ip_source": "neutron",

View File

@ -18,6 +18,8 @@ from openstack import proxy
class BaseImageProxy(six.with_metaclass(abc.ABCMeta, proxy.Proxy)):
retriable_status_codes = [503]
def create_image(
self, name, filename=None,
container=None,

View File

@ -17,7 +17,6 @@ import time
import warnings
from openstack.cloud import exc
from openstack.cloud import _utils
from openstack import exceptions
from openstack.image import _base_proxy
from openstack.image.v2 import image as _image
@ -202,34 +201,15 @@ class Proxy(_base_proxy.BaseImageProxy):
for count in utils.iterate_timeout(
timeout,
"Timeout waiting for the image to import."):
try:
if image_id is None:
response = self.get(
'/tasks/{id}'.format(id=glance_task.id))
status = self._connection._get_and_munchify(
key=None, data=response)
except exc.OpenStackCloudHTTPError as e:
if e.response.status_code == 503:
# Clear the exception so that it doesn't linger
# and get reported as an Inner Exception later
_utils._exc_clear()
# Intermittent failure - catch and try again
continue
raise
if image_id is None:
response = self.get(
'/tasks/{id}'.format(id=glance_task.id))
status = self._connection._get_and_munchify(
key=None, data=response)
if status['status'] == 'success':
image_id = status['result']['image_id']
try:
image = self._connection.get_image(image_id)
except exc.OpenStackCloudHTTPError as e:
if e.response.status_code == 503:
# Clear the exception so that it doesn't linger
# and get reported as an Inner Exception later
_utils._exc_clear()
# Intermittent failure - catch and try again
continue
raise
image = self._connection.get_image(image_id)
if image is None:
continue
self.update_image_properties(