Blame SOURCES/sos-bz1859885-kubernetes_ignore_empty_lines.patch

c3caec
From 5c6793e0e9e41ed754020bb7a589587ba647ccb6 Mon Sep 17 00:00:00 2001
c3caec
From: Jan Jansky <jjansky@redhat.com>
c3caec
Date: Fri, 24 Jul 2020 09:21:11 +0200
c3caec
Subject: [PATCH] [kubernetes] ignore blank+empty lines in "kubectl get nodes"
c3caec
 output
c3caec
c3caec
In a theoretical case when the command output contains empty or blank
c3caec
line, we must skip them before finding the first word there.
c3caec
c3caec
Related: #2162
c3caec
Resolves: #2164
c3caec
c3caec
Signed-off-by: Jan Jansky <jjansky@redhat.com>
c3caec
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
c3caec
---
c3caec
 sos/plugins/kubernetes.py | 6 +++++-
c3caec
 1 file changed, 5 insertions(+), 1 deletion(-)
c3caec
c3caec
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
c3caec
index 8fc0eba..b7baae2 100644
c3caec
--- a/sos/plugins/kubernetes.py
c3caec
+++ b/sos/plugins/kubernetes.py
c3caec
@@ -100,7 +100,11 @@ class Kubernetes(Plugin):
c3caec
         nodes = self.collect_cmd_output("%s get nodes" % self.kube_cmd)
c3caec
         if nodes['status'] == 0:
c3caec
             for line in nodes['output'].splitlines()[1:]:
c3caec
-                node = line.split()[0]
c3caec
+                # find first word in the line and ignore empty+blank lines
c3caec
+                words = line.split()
c3caec
+                if not words:
c3caec
+                    continue
c3caec
+                node = words[0]
c3caec
                 self.add_cmd_output(
c3caec
                     "%s describe node %s" % (self.kube_cmd, node),
c3caec
                     subdir='nodes'
c3caec
-- 
c3caec
1.8.3.1
c3caec