diff options
author | Jake Hunsaker <jhunsake@redhat.com> | 2018-01-16 12:03:51 -0500 |
---|---|---|
committer | Bryn M. Reeves <bmr@redhat.com> | 2018-04-17 15:44:44 +0100 |
commit | 2962b6897fafb5b6995e66867190b87f8f95d505 (patch) | |
tree | c975f7f5f7d862b4149ac19ca092b61549cab7f5 | |
parent | 5dee8f1069fd17aeddba121af6fcda4830aa74f3 (diff) | |
download | sos-2962b6897fafb5b6995e66867190b87f8f95d505.tar.gz |
[kubernetes] Fix collection of pod logs
Corrects a few problems with the collection of pod logs via kubectl.
First, no longer require the 'all' plugin option, and make pod
collection a check of its own. Second, fix a malformed kubectl command
to actually collect the logs from a given pod.
Additionally, no longer collect duplicate --all-namespaces output if we
collect this output separately for each namespace.
Closes: #1189
Resolves: #1190
Signed-off-by: Jake Hunsaker <jhunsake@redhat.com>
Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r-- | sos/plugins/kubernetes.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py index 1010354c..252cdd74 100644 --- a/sos/plugins/kubernetes.py +++ b/sos/plugins/kubernetes.py @@ -90,9 +90,10 @@ class kubernetes(Plugin, RedHatPlugin): "{} get -o json pv".format(kube_cmd), "{} get --raw /metrics".format(kube_cmd) ]) - if self.get_option('all'): - for n in knsps: - knsp = '--namespace=%s' % n + + for n in knsps: + knsp = '--namespace=%s' % n + if self.get_option('all'): k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp) self.add_cmd_output('%s events' % k_cmd) @@ -115,7 +116,7 @@ class kubernetes(Plugin, RedHatPlugin): '%s describe %s %s' % (k_cmd, res, k)) if self.get_option('podlogs'): - k_cmd = '%s get %s' % (kube_cmd, knsp) + k_cmd = '%s %s' % (kube_cmd, knsp) r = self.get_command_output('%s get pods' % k_cmd) if r['status'] == 0: pods = [p.split()[0] for p in @@ -123,9 +124,10 @@ class kubernetes(Plugin, RedHatPlugin): for pod in pods: self.add_cmd_output('%s logs %s' % (k_cmd, pod)) - k_cmd = '%s get --all-namespaces=true' % kube_cmd - for res in resources: - self.add_cmd_output('%s %s' % (k_cmd, res)) + if not self.get_option('all'): + k_cmd = '%s get --all-namespaces=true' % kube_cmd + for res in resources: + self.add_cmd_output('%s %s' % (k_cmd, res)) def postproc(self): # First, clear sensitive data from the json output collected. |