From: huangtianhua Date: Wed, 11 Dec 2013 09:35:13 +0000 (+0800) Subject: Fix KeyError while generating a WSGI response X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=92e058d6800e1cb33a0359cdc5c079b55612525c;p=openstack-build%2Fcinder-build.git Fix KeyError while generating a WSGI response The KeyError exception raised while generating a WSGI response based on the 413 exception. Because there may be no "Retry-After" attribute in the exception headers. Change-Id: I89eb1878acc2195775be17fbcba8088f2e00bac1 Closes-Bug: #1259867 --- diff --git a/cinder/api/openstack/wsgi.py b/cinder/api/openstack/wsgi.py index 70d127e81..f07f75a8e 100644 --- a/cinder/api/openstack/wsgi.py +++ b/cinder/api/openstack/wsgi.py @@ -1169,8 +1169,9 @@ class Fault(webob.exc.HTTPException): 'message': gettextutils.get_localized_message(explanation, locale)}} if code == 413: - retry = self.wrapped_exc.headers['Retry-After'] - fault_data[fault_name]['retryAfter'] = retry + retry = self.wrapped_exc.headers.get('Retry-After', None) + if retry: + fault_data[fault_name]['retryAfter'] = retry # 'code' is an attribute on the fault tag itself metadata = {'attributes': {fault_name: 'code'}}