xenapi: no glance upload retry on 401 error
It is possible for a token to expire during a very long image upload. If this happens, there is little point in retrying the upload, as it is most likely to fail again for the same reason. Fixes bug 1199454 Change-Id: Id699135a8ec4c603671b16f0127d0b2cd2a55855
This commit is contained in:
parent
80ccf6dd95
commit
8e81e069a1
@ -197,10 +197,20 @@ def _upload_tarball(staging_path, image_id, glance_host, glance_port,
|
||||
logging.info("Wrote %d bytes to %s" % (bytes_written, url))
|
||||
|
||||
resp = conn.getresponse()
|
||||
if resp.status != httplib.OK:
|
||||
logging.error("Unexpected response while writing image data to %s: "
|
||||
"Response Status: %i, Response body: %s"
|
||||
% (url, resp.status, resp.read()))
|
||||
if resp.status == httplib.OK:
|
||||
return
|
||||
|
||||
logging.error("Unexpected response while writing image data to %s: "
|
||||
"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))
|
||||
else:
|
||||
raise RetryableError("Unexpected response [%i] while uploading "
|
||||
"image [%s] "
|
||||
"to glance host [%s:%s]"
|
||||
|
Loading…
Reference in New Issue
Block a user