Fix slash handling in KubernetesConnector's get_request
The KubernetesConnector can generate URLs that contain '//' when joining the API prefix with the endpoint. This causes errors in newer versions of the Kubernetes API and breaks agent startup since it uses the API to determine the node hostname. This patch changes KubernetesConnector.get_request()'s behavior to remove extraneous slashes when necessary. Change-Id: Icd45b0eb4a9e5535c7c9d95bda209ec186036fab
This commit is contained in:
parent
9ff337881b
commit
5f849db6a3
|
@ -146,7 +146,14 @@ class KubernetesConnector(object):
|
|||
"""Sends request to Kubernetes API with given endpoint.
|
||||
Will retry the request once, with updated token/cert, if unauthorized.
|
||||
"""
|
||||
request_url = "{}/{}".format(self.api_url, request_endpoint)
|
||||
api_url = self.api_url
|
||||
if api_url[-1] == '/':
|
||||
api_url = api_url[:-1]
|
||||
|
||||
if request_endpoint[0] == '/':
|
||||
request_endpoint = request_endpoint[1:]
|
||||
|
||||
request_url = "{}/{}".format(api_url, request_endpoint)
|
||||
result = requests.get(request_url,
|
||||
timeout=self.connection_timeout,
|
||||
headers=self.api_request_header,
|
||||
|
|
Loading…
Reference in New Issue