Blame SOURCES/sos-bz1859888-kubernetes-indexerror-on-nodes.patch

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