Check for 204 case in DynamicVendorData

Before b9587587c2 we were doing
an explicit check on the response status codes, but after
that change, we just rely on the bool override in requests.Reponse
which is True for any repsonse code less than 400. In the 204 case
we won't have response text, so we should handle that before trying
to load the json repsonse text. Because TypeError and ValueError are
handled it would just result in a warning if you got a 204, unless
CONF.api.vendordata_dynamic_failure_fatal was True in which case
it's a failure (as shown in the unit test update here).

Change-Id: Iba95fd0112ae4510ef21fdb44fcb281b14567c07
Closes-Bug: #1669084
This commit is contained in:
Matt Riedemann
2017-03-01 14:16:29 -05:00
parent 3a2a181796
commit 3c1943f8d9
3 changed files with 12 additions and 4 deletions

View File

@@ -96,7 +96,7 @@ class DynamicVendorData(vendordata.VendorDataDriver):
res = self.session.request(url, 'POST', data=jsonutils.dumps(body),
verify=verify, headers=headers,
timeout=timeout)
if res:
if res and res.text:
# TODO(mikal): Use the Cache-Control response header to do some
# sensible form of caching here.
return jsonutils.loads(res.text)