Merge "xenapi: no image upload retry on certain errors"

This commit is contained in:
Jenkins 2013-08-08 16:02:56 +00:00 committed by Gerrit Code Review
commit 3475662e02

View File

@ -207,17 +207,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 "
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]"
% (image_id, glance_host, glance_port))
% (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))
% (resp.status, image_id,
glance_host, glance_port))
finally:
conn.close()