xenapi: no image upload retry on certain errors
There are a few upload errors that glance plugin should not retry upload on, as it will fail again. This patch changes upload to not retry on the following conditions in addition to the 401 error that it already handles: - CONFLICT - REQUEST_ENTITY_TOO_LARGE - PRECONDITION_FAILED - FORBIDDEN Fixes bug 1203726 Change-Id: I538a4f9b133169b2e398e7dfcb3af58fef204f03
This commit is contained in:
@@ -204,17 +204,23 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
|
||||
"Response Status: %i, Response body: %s"
|
||||
% (url, resp.status, resp.read()))
|
||||
|
||||
if resp.status == httplib.UNAUTHORIZED:
|
||||
# NOTE(johngarbutt): little point in retrying when token invalid
|
||||
raise PluginError("Unauthorized error while uploading "
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
% (image_id, glance_host, glance_port))
|
||||
if resp.status in (httplib.UNAUTHORIZED,
|
||||
httplib.REQUEST_ENTITY_TOO_LARGE,
|
||||
httplib.PRECONDITION_FAILED,
|
||||
httplib.CONFLICT,
|
||||
httplib.FORBIDDEN):
|
||||
# No point in retrying for these conditions
|
||||
raise PluginError("Got Error response [%i] while uploading "
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
% (resp.status, image_id,
|
||||
glance_host, glance_port))
|
||||
else:
|
||||
raise RetryableError("Unexpected response [%i] while uploading "
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
% (resp.status, image_id, glance_host, glance_port))
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
% (resp.status, image_id,
|
||||
glance_host, glance_port))
|
||||
finally:
|
||||
conn.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user