aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Stanley <jonstanley@gmail.com>2017-09-20 19:01:28 -0400
committerBryn M. Reeves <bmr@redhat.com>2017-10-31 15:53:12 +0000
commitefb44b322976440a663d5c8a3c5b5757b86c4315 (patch)
tree288ccbfab33b1db75cd901b69e6b9bd31f86c5f2
parentd5ac6cd768acbd6a8d2d1de2ec26f127272089f2 (diff)
downloadsos-efb44b322976440a663d5c8a3c5b5757b86c4315.tar.gz
[kubernetes] Do not collect all namespaces unless requested
Collecting all namespaces on a cluster can be extremely time consuming. Do not do this unless specifically requested, repurposing the 'all' module option. Fixes: #1108 Signed-off-by: Jon Stanley <jonstanley@gmail.com> Signed-off-by: Bryn M. Reeves <bmr@redhat.com>
-rw-r--r--sos/plugins/kubernetes.py53
1 files changed, 26 insertions, 27 deletions
diff --git a/sos/plugins/kubernetes.py b/sos/plugins/kubernetes.py
index bb7f24a0..22f6656e 100644
--- a/sos/plugins/kubernetes.py
+++ b/sos/plugins/kubernetes.py
@@ -30,10 +30,10 @@ class kubernetes(Plugin, RedHatPlugin):
files = ("/etc/origin/master/master-config.yaml",)
option_list = [
- ("all", "also collect --all-namespaces output separately",
- 'fast', True),
+ ("all", "also collect all namespaces output separately",
+ 'slow', False),
("describe", "capture descriptions of all kube resources",
- 'fast', True),
+ 'fast', False),
("podlogs", "capture logs for pods", 'slow', False),
]
@@ -88,29 +88,29 @@ class kubernetes(Plugin, RedHatPlugin):
"{} get -o json nodes".format(kube_cmd),
"{} get -o json pv".format(kube_cmd)
])
+ if self.get_option('all'):
+ for n in knsps:
+ knsp = '--namespace=%s' % n
+ k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
- for n in knsps:
- knsp = '--namespace=%s' % n
- k_cmd = '%s %s %s' % (kube_cmd, kube_get_cmd, knsp)
-
- self.add_cmd_output('%s events' % k_cmd)
-
- for res in resources:
- self.add_cmd_output('%s %s' % (k_cmd, res))
+ self.add_cmd_output('%s events' % k_cmd)
- if self.get_option('describe'):
- # need to drop json formatting for this
- k_cmd = '%s get %s' % (kube_cmd, knsp)
for res in resources:
- r = self.get_command_output(
- '%s %s' % (k_cmd, res))
- if r['status'] == 0:
- k_list = [k.split()[0] for k in
- r['output'].splitlines()[1:]]
- for k in k_list:
- k_cmd = '%s %s' % (kube_cmd, knsp)
- self.add_cmd_output(
- '%s describe %s %s' % (k_cmd, res, k))
+ self.add_cmd_output('%s %s' % (k_cmd, res))
+
+ if self.get_option('describe'):
+ # need to drop json formatting for this
+ k_cmd = '%s get %s' % (kube_cmd, knsp)
+ for res in resources:
+ r = self.get_command_output(
+ '%s %s' % (k_cmd, res))
+ if r['status'] == 0:
+ k_list = [k.split()[0] for k in
+ r['output'].splitlines()[1:]]
+ for k in k_list:
+ k_cmd = '%s %s' % (kube_cmd, knsp)
+ self.add_cmd_output(
+ '%s describe %s %s' % (k_cmd, res, k))
if self.get_option('podlogs'):
k_cmd = '%s get %s' % (kube_cmd, knsp)
@@ -121,10 +121,9 @@ class kubernetes(Plugin, RedHatPlugin):
for pod in pods:
self.add_cmd_output('%s logs %s' % (k_cmd, pod))
- if 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))
+ 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.