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

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