From 466be3b6568b643605d826e5aa26d9a344cc74ae Mon Sep 17 00:00:00 2001 From: Jason Date: Fri, 15 Mar 2019 10:57:57 -0500 Subject: [PATCH] Use endpoint_override in version negotiation Change [1] introduced the usage of endpoint_filter when deciding which endpoint to use during version negotiation. This requires properly setting interface/region/service_type in order to properly pick the endpoint. But, sometimes (for example in Kolla-ansible), the endpoint url is explicitly defined. In the event of the endpoint being explicitly defined, it should take priority here. It should be noted that even though SessionClient extends from keystoneauth1's adapter.LegacyJsonAdapter, the `request` function within _make_simple_request is being called on the nested Session object, not the Adapter itself. If it was called on the Adapter this problem wouldn't exist, as the `endpoint_override` (or `endpoint`) kwarg passed in to the constructor of the SessionClient would already take precedence. Additionally: Adds a release note to the older branch as this is a fix that needs to be released and is worthy of change visibility in release notes. [1]: I42b66daea1f4397273a3f4eb1638abafb3bb28ce Change-Id: I69dc2c88648ba1d09a9ad3ab3435662e8d1ea6ff Related-Bug: #1818295 (cherry picked from commit 8071d5de57c728ce09d25d04c8c9fe48cd7db42e) (cherry picked from commit b40630f3b3e747ae4a26d31e8e292554b99713f2) --- ironicclient/common/http.py | 3 ++- ironicclient/tests/unit/common/test_http.py | 1 + ...xes-endpoint-override-for-version-e6d25da654f0a7ff.yaml | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fixes-endpoint-override-for-version-e6d25da654f0a7ff.yaml diff --git a/ironicclient/common/http.py b/ironicclient/common/http.py index 3177c98cf..5e677ad24 100644 --- a/ironicclient/common/http.py +++ b/ironicclient/common/http.py @@ -620,7 +620,8 @@ def _make_simple_request(self, conn, method, url): # NOTE: conn is self.session for this class return conn.request(url, method, raise_exc=False, user_agent=USER_AGENT, - endpoint_filter=endpoint_filter) + endpoint_filter=endpoint_filter, + endpoint_override=self.endpoint_override) @with_retries def _http_request(self, url, method, **kwargs): diff --git a/ironicclient/tests/unit/common/test_http.py b/ironicclient/tests/unit/common/test_http.py index 263c7800e..b8afad0cf 100644 --- a/ironicclient/tests/unit/common/test_http.py +++ b/ironicclient/tests/unit/common/test_http.py @@ -741,6 +741,7 @@ def test_make_simple_request(self): 'service_type': 'baremetal', 'region_name': '' }, + endpoint_override='http://127.0.0.1', user_agent=http.USER_AGENT) self.assertEqual(res, session.request.return_value) diff --git a/releasenotes/notes/fixes-endpoint-override-for-version-e6d25da654f0a7ff.yaml b/releasenotes/notes/fixes-endpoint-override-for-version-e6d25da654f0a7ff.yaml new file mode 100644 index 000000000..c88e3b47d --- /dev/null +++ b/releasenotes/notes/fixes-endpoint-override-for-version-e6d25da654f0a7ff.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes an issue where an endpoint_override was not considered when + performing version negotiation, which would can result in the client + attempting to base version negotiation off of an entry in the service + catalog as opposed to an endpoint_override.