From 482029d991e1aa075aafb122cbeee911afad341c Mon Sep 17 00:00:00 2001 From: Pavel Moravec Date: Thu, 23 Jul 2020 15:35:31 +0200 Subject: [PATCH] [kubernetes] ignore blank+empty lines in "kubectl get nodes" output In a theoretical case when the command output contains empty or blank line, we must skip them before finding the first word there. Resolves: #2162 Signed-off-by: Pavel Moravec Signed-off-by: Jake Hunsaker --- sos/plugins/kubernetes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py index 03f2c498..5f21fa3d 100644 --- a/sos/plugins/kubernetes.py +++ b/sos/plugins/kubernetes.py @@ -105,7 +105,11 @@ class Kubernetes(Plugin): nodes = self.collect_cmd_output("%s get nodes" % self.kube_cmd) if nodes['status'] == 0: for line in nodes['output'].splitlines()[1:]: - node = line.split()[0] + # find first word in the line and ignore empty+blank lines + words = line.split() + if not words: + continue + node = words[0] self.add_cmd_output( "%s describe node %s" % (self.kube_cmd, node), subdir='nodes' -- 2.26.2