summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Goddard <mark@stackhpc.com>2019-08-12 16:19:37 +0100
committerMark Goddard <mark@stackhpc.com>2019-12-04 11:26:01 +0000
commit0bd26cc47ed51d19e07280db9e770ad09edd2bf8 (patch)
treee3b04134588e934ed87006658020cd5a59ec2403
parent42faaabdeeaa45c8916f601ece2ca60f37443a3d (diff)
downloadpython-ironicclient-stable/stein.tar.gz
Fix AttributeError in negotiate_versionstein-eolstein-em2.7.3stable/stein
Seen in kolla-ansible CI, if ironic inspector starts up before ironic API is properly up, we see the following error: The PXE filter DnsmasqFilter, state=initialized encountered an exception: StrictVersion instance has no attribute 'version'; resetting the filter: AttributeError: StrictVersion instance has no attribute 'version' Example: http://paste.openstack.org/show/756342/ The usual cause of this error is when StrictVersion is initialised with a version of None. This suggests to me that max_ver is None. This leads to an exception being raised that circumvents the client's retry mechanisms. In the particular case of kolla-ansible CI, Ironic API is behind a load balancer, and all backends are down resulting in a 503. The lack of a retry caused ironic inspector to fail on startup. This patch catches the case where we get a 4xx or 5xx return code when checking the version, and raises an error that works with the client's retry mechanisms. Change-Id: Ib62ca3ee4626084e5e9b90e93e4fa97938023457 Story: 2006393 Task: 36266 (cherry picked from commit 0e9bf337f1f6aa41f67df2966dacf9e8e897b7da)
-rw-r--r--ironicclient/common/http.py6
-rw-r--r--releasenotes/notes/fix-negotiate-version-503-c3cb8d1d4901541a.yaml8
2 files changed, 13 insertions, 1 deletions
diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py
index b78c5a6..9fab68b 100644
--- a/ironicclient/common/http.py
+++ b/ironicclient/common/http.py
@@ -118,7 +118,11 @@ class VersionNegotiationMixin(object):
str(self.os_ironic_api_version).split('.')[0])
else:
base_version = API_VERSION
- return self._make_simple_request(conn, 'GET', base_version)
+ # Raise exception on client or server error.
+ resp = self._make_simple_request(conn, 'GET', base_version)
+ if not resp.ok:
+ raise exc.from_response(resp, method='GET', url=base_version)
+ return resp
version_overridden = False
diff --git a/releasenotes/notes/fix-negotiate-version-503-c3cb8d1d4901541a.yaml b/releasenotes/notes/fix-negotiate-version-503-c3cb8d1d4901541a.yaml
new file mode 100644
index 0000000..0b13e25
--- /dev/null
+++ b/releasenotes/notes/fix-negotiate-version-503-c3cb8d1d4901541a.yaml
@@ -0,0 +1,8 @@
+---
+fixes:
+ - |
+ Fixes an issue where some failure modes of communication with the Ironic
+ API could result in an exception that circumvents the client's retry
+ mechanisms. In particular this includes HTTP 503 service unavailable which
+ is seen when Ironic operates behind a load balancer, and no backend is
+ available to handle the request.