From 71d6cf9676ea5e258edb0de7fd9864845fcab8d5 Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Wed, 3 Oct 2018 08:44:48 +0200 Subject: [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 --- sos/plugins/kubernetes.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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', -- cgit