From 7aa6f8465ca4d0aed656a1faf271a597fbdb6f05 Mon Sep 17 00:00:00 2001 From: Sulochan Acharya Date: Mon, 29 Jul 2013 06:58:07 -0500 Subject: [PATCH] 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 --- .../xenapi/etc/xapi.d/plugins/glance | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance index e99a651981..9c4bc20e92 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance @@ -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()