diff options
author | Pavel Moravec <pmoravec@redhat.com> | 2018-10-03 08:44:48 +0200 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2019-03-18 11:59:48 +0000 |
commit | 71d6cf9676ea5e258edb0de7fd9864845fcab8d5 (patch) | |
tree | e5f8c547a63edb159618313a7482103df6f25508 | |
parent | d9e7d4c2c57c18b75bbe65dd15de6ee16da5396f (diff) | |
download | sos-71d6cf9676ea5e258edb0de7fd9864845fcab8d5.tar.gz |
[kubernetes] improve parsing namespaces
Handle (theoretical) cases when "kubectl get namespace" returns a line with
white characters only, and prevent IndexError to be raised.
Resolves: #1442
Signed-off-by: Pavel Moravec <pmoravec@redhat.com>
-rw-r--r-- | sos/plugins/kubernetes.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py index 07efc296..2d0b5552 100644 --- a/sos/plugins/kubernetes.py +++ b/sos/plugins/kubernetes.py @@ -69,7 +69,9 @@ class kubernetes(Plugin, RedHatPlugin): # get all namespaces in use kn = self.get_command_output('%s get namespaces' % kube_cmd) - knsps = [n.split()[0] for n in kn['output'].splitlines()[1:] if n] + # namespace is the 1st word on line, until the line has spaces only + kn_output = kn['output'].splitlines()[1:] + knsps = [n.split()[0] for n in kn_output if n and len(n.split())] resources = [ 'deployments', |