From 39ff609835cfe82fb97886f1300ecd42f601768c Mon Sep 17 00:00:00 2001 From: Tristan Cacqueray Date: Thu, 8 Jul 2021 18:35:08 +0000 Subject: [PATCH] kubernetes: handle situation where the configuration is empty This change is a follow-up to I5bdd369f6c9a78e5f79a926d8690f285fda94af9 where it missed the case where the configuration could be None. Change-Id: I613cbf82932e14a8048e4dcfbf539fe1d83bf9e3 --- nodepool/driver/utils_k8s.py | 9 +++++---- .../notes/fix-k8s-conf-loading-a54a371a3392f665.yaml | 6 ++++++ 2 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix-k8s-conf-loading-a54a371a3392f665.yaml diff --git a/nodepool/driver/utils_k8s.py b/nodepool/driver/utils_k8s.py index ef8329a3f..a9fa35082 100644 --- a/nodepool/driver/utils_k8s.py +++ b/nodepool/driver/utils_k8s.py @@ -41,10 +41,11 @@ def get_client(log, context, extra_client_constructor=None): token, ca, client, extra_client = None, None, None, None try: conf = _get_conf(log, context) - auth = conf.configuration.api_key.get('authorization') - if auth: - token = auth.split()[-1] - if conf.configuration.ssl_ca_cert: + if conf: + auth = conf.configuration.api_key.get('authorization') + if auth: + token = auth.split()[-1] + if conf and conf.configuration.ssl_ca_cert: with open(conf.configuration.ssl_ca_cert) as ca_file: ca = ca_file.read() ca = base64.b64encode(ca.encode('utf-8')).decode('utf-8') diff --git a/releasenotes/notes/fix-k8s-conf-loading-a54a371a3392f665.yaml b/releasenotes/notes/fix-k8s-conf-loading-a54a371a3392f665.yaml new file mode 100644 index 000000000..fdf41db38 --- /dev/null +++ b/releasenotes/notes/fix-k8s-conf-loading-a54a371a3392f665.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Fix Kubernetes in-cluster configuration loading if no local config + is present. The previous release missed a fallback case which has + been corrected.