Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't collect KUB stats, plugin can't be used #3484

Open
hchybz opened this issue Jan 18, 2024 · 20 comments · May be fixed by #3509
Open

can't collect KUB stats, plugin can't be used #3484

hchybz opened this issue Jan 18, 2024 · 20 comments · May be fixed by #3509

Comments

@hchybz
Copy link

hchybz commented Jan 18, 2024

Can't figure how to make kub plugin correctly used. Does not appear in documentation, but present in plugin directory

Help please

root@k8s-master:~/sos# grep -v ^# sos.conf
[global]
verbose = 3
batch = yes

[report]
enable-plugins = kubernetes

[collect]

[clean]

[plugin_options]

root@k8s-master:~/sos# kubectl get no
NAME          STATUS   ROLES           AGE   VERSION
k8s-master    Ready    control-plane   14h   v1.28.1
k8s-worker1   Ready    <none>          14h   v1.28.1
k8s-worker2   Ready    <none>          14h   v1.28.1

root@k8s-master:~/sos# sos report --enable-plugins kubernetes -vvv --batch 

WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module.

sosreport (version 4.6.1)

set sysroot to '/' (default)
Network devices not enumerated by nmcli. Will attempt to manually compile list of devices.
[sos.report:setup] executing 'sos report --enable-plugins kubernetes -vvv --batch'
[sos.report:setup] using 'none' preset defaults ()
[sos.report:setup] effective options now: --batch --enable-plugins kubernetes --tmp-dir /tmp -vvv
a non-existing plugin (kubernetes) was specified in the command line.
root@k8s-master:~/sos# 
@jcastill
Copy link
Member

jcastill commented Jan 18, 2024

Some questions to move the diagnostics of the issue, until our maintainers can comment:

  • What do you get when you run:

    sos report --list-plugins

  • Can you run the command with --debug? I.e. simplyfing the command:

    sos report -o kubernetes -vvv --batch --debug

  • Where's sos installed? I.e. if you run 'which sos' what do you get?

@hchybz
Copy link
Author

hchybz commented Jan 18, 2024

Thx for your very quick answer.. can't find what I'm doing wrong

root@k8s-master:~# dpkg -l| grep sos
root@k8s-master:~# sos 
root@k8s-master:~# apt install gh
root@k8s-master:~# export GH_TOKEN=foobar...
root@k8s-master:~# gh repo clone sosreport/sos
Cloning into 'sos'...
remote: Enumerating objects: 33876, done.
remote: Counting objects: 100% (9054/9054), done.
remote: Compressing objects: 100% (3611/3611), done.
remote: Total 33876 (delta 5633), reused 5966 (delta 5432), pack-reused 24822
Receiving objects: 100% (33876/33876), 19.11 MiB | 4.39 MiB/s, done.
Resolving deltas: 100% (24852/24852), done.

root@k8s-master:~/sos# grep -v ^# /root/sos/sos.conf 
[global]
verbose = 3
batch = yes

[report]
enable-plugins = kubernetes

[collect]
[clean]
[plugin_options]


root@k8s-master:~/sos# ./bin/sos report --config /root/sos/sos.conf -l
WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims to use for detecting binary files. A less effective method will be used. It is recommended to install proper python3-magic package with the module.
sosreport (version 4.6.1)

set sysroot to '/' (default)
Network devices not enumerated by nmcli. Will attempt to manually compile list of devices.
[sos.report:setup] executing 'sos report --config /root/sos/sos.conf -l'
[sos.report:setup] using 'none' preset defaults ()
[sos.report:setup] effective options now: --batch --config-file /root/sos/sos.conf --enable-plugins kubernetes --list-plugins -vvv 
a non-existing plugin (kubernetes) was specified in the command line.

root@k8s-master:~/sos# ls -al sos/report/plugins/kubernetes.py 
-rw-r--r-- 1 root root 8206 Jan 18 12:44 sos/report/plugins/kubernetes.py

what you've asked

root@k8s-master:~/sos# /root/sos/bin/sos report -o kubernetes -vvv --batch --debug

WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims
to use for detecting binary files. A less effective method will be used.
It is recommended to install proper python3-magic package with the
module.

WARNING: Unable to read configuration file /etc/sos/sos.conf : No such file or directory

sosreport (version 4.6.1)

set sysroot to '/' (default)
Network devices not enumerated by nmcli. Will attempt to manually compile list of devices.
[sos.report:setup] executing 'sos report -o kubernetes -vvv --batch --debug'
[sos.report:setup] using 'none' preset defaults ()
[sos.report:setup] effective options now: --batch --debug --only-plugins kubernetes -vvv
a non-existing plugin (kubernetes) was specified in the command line.

sos has been installed manually (deb 12 still have 4.0.2).. so not in system path

root@k8s-master:~/sos# sos report --list-plugins
-bash: sos: command not found
root@k8s-master:~/sos# which sos
root@k8s-master:~/sos# 

kub does not appear in plugins, neither active , nor inactive .. strange

root@k8s-master:~/sos# bin/sos report --list-plugins | grep -i kub
WARNING: Failed to load 'magic' module version >= 0.4.20 which sos aims...

@jcastill
Copy link
Member

It could be that's running somehow sos 4.0.2, but it's strange that it failed 'bin/sos report --list-plugins'.
Just to be on the safe side, can you install the magic module version asked in deb 12?
I'll try to launch a vm and reproduce as well.

@hchybz
Copy link
Author

hchybz commented Jan 18, 2024

sure.. 4.0.2 has been uninstalled (my first commands) to be sure .. I'm testing the magic module..

Here is what you've asked

root@k8s-master:~/sos# apt install python3-magic
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  python3-magic
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.
Need to get 14.5 kB of archives.
After this operation, 57.3 kB of additional disk space will be used.
Get:1 file:/etc/apt/mirrors/debian.list Mirrorlist [30 B]
Get:2 https://deb.debian.org/debian bookworm/main amd64 python3-magic all 2:0.4.26-3 [14.5 kB]
Fetched 14.5 kB in 0s (118 kB/s)        
Selecting previously unselected package python3-magic.
(Reading database ... 55909 files and directories currently installed.)
Preparing to unpack .../python3-magic_2%3a0.4.26-3_all.deb ...
Unpacking python3-magic (2:0.4.26-3) ...
Setting up python3-magic (2:0.4.26-3) ...


root@k8s-master:~/sos# /root/sos/bin/sos report -o kubernetes --config-file /root/sos/sos.conf -vvv --batch --debug
sosreport (version 4.6.1)

set sysroot to '/' (default)
Network devices not enumerated by nmcli. Will attempt to manually compile list of devices.
[sos.report:setup] executing 'sos report -o kubernetes --config-file /root/sos/sos.conf -vvv --batch --debug'
[sos.report:setup] using 'none' preset defaults ()
[sos.report:setup] effective options now: --batch --config-file /root/sos/sos.conf --debug --only-plugins kubernetes -vvv
a non-existing plugin (kubernetes) was specified in the command line.

@jcastill
Copy link
Member

jcastill commented Jan 18, 2024

I think I've found the problem and a possible solution - Add DebianPlugin like this:

diff --git a/sos/report/plugins/kubernetes.py b/sos/report/plugins/kubernetes.py
index 5cd416c5..e15418ce 100644
--- a/sos/report/plugins/kubernetes.py
+++ b/sos/report/plugins/kubernetes.py
@@ -9,7 +9,7 @@

-from sos.report.plugins import Plugin, RedHatPlugin, UbuntuPlugin, PluginOpt
+from sos.report.plugins import Plugin, RedHatPlugin, DebianPlugin, UbuntuPlugin, PluginOpt
from fnmatch import translate
import re

@@ -205,7 +205,7 @@ class RedHatKubernetes(Kubernetes, RedHatPlugin):
super(RedHatKubernetes, self).setup()

-class UbuntuKubernetes(Kubernetes, UbuntuPlugin):
+class UbuntuKubernetes(Kubernetes, UbuntuPlugin, DebianPlugin):

packages = ('kubernetes',)
files = (

I'm sending a PR now

jcastill added a commit to jcastill/sos that referenced this issue Jan 18, 2024
Add DebianPlugin to the list of imports and
the class UbuntuKubernetes.

Related: sosreport#3484

Signed-off-by: Jose Castillo <jcastillo@redhat.com>
TurboTurtle pushed a commit that referenced this issue Jan 19, 2024
Add DebianPlugin to the list of imports and
the class UbuntuKubernetes.

Related: #3484

Signed-off-by: Jose Castillo <jcastillo@redhat.com>
@hchybz
Copy link
Author

hchybz commented Jan 22, 2024

Hi José.

Thx for the fix. tested on same server (git pull from sos directoty).. it produces some logs but I still have questions :

  • sos report -l does not show kubernetes as an inactive plugin , but show that some plugin options are avail . why ?
  • i browsed all logs produced by /root/sos/bin/sos report -o kubernetes -vvv --batch --debug and there no much interesting informations except logs . I would expect to find the output (txt or json) of some classical "kubectl get XXX -o wide" commands .

moreover some of the expected commands are described in the kubernetes.py plugin .

how shall I get those infos ?

root@k8s-master:~# kubectl get no -o wide -o json
root@k8s-master:~# kubectl get po -A -o wide -o json
root@k8s-master:~# kubectl get namespace -o json
root@k8s-master:/var# kubectl get pods -A -o wide -o json
...

Thx !

@jcastill
Copy link
Member

Hi Hervé,

sos report -l does not show kubernetes as an inactive plugin , but show that some plugin
options are avail . why ?

I'm not sure I understand. Can you paste the output you get with that command? This is what I get in my Debian cluster:

$ bin/sos report -l
sosreport (version 4.6.1)

The following plugins are currently enabled:

[...]
kubernetes Kubernetes container orchestration platform
[...]
The following plugin options are available:
[...]
kubernetes.all off collect all namespace output separately
kubernetes.describe off collect describe output of all resources
kubernetes.podlogs off capture stdout/stderr logs from pods
kubernetes.podlogs-filter only collect logs from pods matching this pattern
[...]

Which is the expected output, afaik.

i browsed all logs produced by /root/sos/bin/sos report -o kubernetes -vvv --batch --debug and there
no much interesting informations except logs . I would expect to find the output (txt or json) of some
classical "kubectl get XXX -o wide" commands .
moreover some of the expected commands are described in the kubernetes.py plugin .

What do you have in the file sos_logs/sos.log? That should tell you what the plugin tried to capture and if it failed or not. In my cluster, I get this:

2024-01-24 10:11:07,606 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get namespaces'
2024-01-24 10:11:07,607 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get projects'
2024-01-24 10:11:07,607 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get pvs'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --raw /metrics'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true deployments'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true ingresses'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true limitranges'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true pods'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true policies'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true pvc'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true rc'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true resourcequotas'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true routes'
2024-01-24 10:11:57,644 INFO: [plugin:kubernetes] added cmd output 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true services'
2024-01-24 10:12:08,492 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get namespaces'
2024-01-24 10:12:58,534 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get projects'
2024-01-24 10:13:48,576 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get pvs'
2024-01-24 10:14:38,621 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --raw /metrics'
2024-01-24 10:14:48,658 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true deployments'
2024-01-24 10:15:38,701 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true ingresses'
2024-01-24 10:16:28,740 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true limitranges'
2024-01-24 10:17:18,778 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true pods'
2024-01-24 10:18:08,829 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true policies'
2024-01-24 10:18:58,872 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true pvc'
2024-01-24 10:19:48,923 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true rc'
2024-01-24 10:20:38,966 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true resourcequotas'
2024-01-24 10:21:29,009 INFO: [plugin:kubernetes] collecting output of 'kubectl --kubeconfig=/etc/kubernetes/admin.conf get --all-namespaces=true routes'

Do you have something similar in your sos.log?

@hchybz
Copy link
Author

hchybz commented Jan 26, 2024

Hi José

Seems that all options are not active...

root@k8s-master:~/sos# bin/sos report  -l |grep kub
 kubernetes           Kubernetes container orchestration platform
 kubernetes.all            off             collect all namespace output separately
 kubernetes.describe       off             collect describe output of all resources
 kubernetes.podlogs        off             capture stdout/stderr logs from pods
 kubernetes.podlogs-filter                 only collect logs from pods matching this pattern

@jcastill
Copy link
Member

Hi Hervé,

That's expected - the options are off by default:

    option_list = [
        PluginOpt('all', default=False,
                  desc='collect all namespace output separately'),
        PluginOpt('describe', default=False,
                  desc='collect describe output of all resources'),
        PluginOpt('podlogs', default=False,
                  desc='capture stdout/stderr logs from pods'),
        PluginOpt('podlogs-filter', default='', val_type=str,
                  desc='only collect logs from pods matching this pattern')
    ]

If you want to enable them, you have to do it explicitly on the command line. I.e., with something like this:

sos report -o kubernetes -k kubernetes.all=True,kubernetes.describe=True,kubernetes.podlogs=True

Basically:

-k PLUGNAME.PLUGOPT[=VALUE], --plugin-option=PLUGNAME.PLUGOPT[=VALUE]

Try that and see if that works for your system.

@hchybz
Copy link
Author

hchybz commented Jan 26, 2024

root@k8s-worker2:~/sos# bin/sos report -o kubernetes -k kubernetes.all=True,kubernetes.describe=True,kubernetes.podlogs=True --config-file=/root/sos/sos.conf --batch -vvv
root@k8s-worker2:~/sos# cd /var/tmp/
root@k8s-worker2:/var/tmp# tar xvf sosreport-k8s-worker2-2024-01-26-cxnmopp.tar.xz
sosreport-k8s-worker2-2024-01-26-cxnmopp/version.txt
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_reports/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_reports/manifest.json
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_reports/sos.html
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_reports/sos.json
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_reports/sos.txt
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_logs/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_logs/sos.log
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_logs/ui.log
sosreport-k8s-worker2-2024-01-26-cxnmopp/
sosreport-k8s-worker2-2024-01-26-cxnmopp/environment
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/kubernetes/
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/kubernetes/kubelet.conf
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/kubernetes/manifests/
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/kubernetes/pki/
sosreport-k8s-worker2-2024-01-26-cxnmopp/etc/kubernetes/pki/ca.crt
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_cdk.master.auth-webhook
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kube-apiserver
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kube-controller-manager
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kube-proxy
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kube-scheduler
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kubelet
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_snap.kube-apiserver.daemon
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_snap.kube-controller-manager.daemon
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_snap.kube-proxy.daemon
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_snap.kube-scheduler.daemon
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_snap.kubelet.daemon
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_strings/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_strings/kubernetes/
sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_strings/kubernetes/journalctl_--no-pager_--unit_kubelet.tailed

almost nothing

root@k8s-worker2:/var/tmp# ls -al sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes
total 52
drwx------ 2 root root 4096 Jan 26 10:39 .
drwxr-xr-x 3 root root 4096 Jan 26 10:38 ..
-rw-r--r-- 1 root root 17 Jan 26 10:38 journalctl_--no-pager_--unit_cdk.master.auth-webhook
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_kube-apiserver
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_kube-controller-manager
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_kube-proxy
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_kube-scheduler
lrwxrwxrwx 1 root root 72 Jan 26 10:39 journalctl_--no-pager_--unit_kubelet -> ../../sos_strings/kubernetes/journalctl_--no-pager_--unit_kubelet.tailed
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_snap.kube-apiserver.daemon
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_snap.kube-controller-manager.daemon
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_snap.kube-proxy.daemon
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_snap.kube-scheduler.daemon
-rw-r--r-- 1 root root 17 Jan 26 10:39 journalctl_--no-pager_--unit_snap.kubelet.daemon
root@k8s-worker2:/var/tmp# cat sosreport-k8s-worker2-2024-01-26-cxnmopp/sos_commands/kubernetes/journalctl_--no-pager_--unit_kube-apiserver
-- No entries --

@hchybz
Copy link
Author

hchybz commented Feb 6, 2024

no news ?

@jcastill
Copy link
Member

jcastill commented Feb 6, 2024

Hi Hervé,

Apologies, I missed your last note. Let me try some tests in my Debian cluster and I'll update tomorrow.

@hchybz
Copy link
Author

hchybz commented Feb 6, 2024

I was NOT on the master ... and did not noticed any warning message. Works fine on the master .

Sorry. I will now try to deep dive into that logs. Thx

@hchybz
Copy link
Author

hchybz commented Feb 6, 2024

in fact style have some questions. Some files are json, some other not.

For instance, the

  • "get node" command is very simple
  • the "describe node" is more interesting but still text and not json

Those 2 commands could be replaced by
"get -o json nodes"

how may I tweak your plugin to switch a command from "normal output" to "-o json" one ?

My aim is to parse your output files .. Parsing a json with JQ is much more simpler as a simple "describe node" file .. Or may be we could have both ?

Thx

Rv

@arif-ali
Copy link
Member

arif-ali commented Feb 6, 2024

I agree, parsing with jq is nice

I would prefer to have both text and json, I think we have a few plugins that do this already

@jcastill
Copy link
Member

jcastill commented Feb 6, 2024

I think we do it nicely in the ceph_mon plugin, with a directory for the jsons. And in storcli we parse an option to get the dumps as json optionally, but we are probably better doing json and not json by default. I'll work on a PR tomorrow to make this happen.

@hchybz
Copy link
Author

hchybz commented Feb 7, 2024

José ?

I'm not very good in python (was bred with PERL).. but i managed to modify your plugin to get what i want

107         if nodes['status'] == 0:
108             for line in nodes['output'].splitlines()[1:]:
109                 # find first word in the line and ignore empty+blank lines
110                 words = line.split()
111                 if not words:
112                     continue
113                 node = words[0]
114                 print('[##LOOP#NODE#]:%s\n\n' % node)
115                 #self.add_cmd_output(
116                 #    "%s describe node %s" % (self.kube_cmd, node),
117                 #    subdir='nodes'
118                 #)
119                 self.add_cmd_output("%s %s node %s" % (self.kube_cmd,kube_get_cmd, node), subdir='nodes')

produces what expected

root@k8s-master:~/sos# file /var/tmp/sosreport-k8s-master-2024-02-07-qclizgf/sos_commands/kubernetes/nodes/*
/var/tmp/sosreport-k8s-master-2024-02-07-qclizgf/sos_commands/kubernetes/nodes/kubectl_--kubeconfig_.etc.kubernetes.admin.conf_get_-o_json_node_k8s-master:  JSON text data
/var/tmp/sosreport-k8s-master-2024-02-07-qclizgf/sos_commands/kubernetes/nodes/kubectl_--kubeconfig_.etc.kubernetes.admin.conf_get_-o_json_node_k8s-worker1: JSON text data
/var/tmp/sosreport-k8s-master-2024-02-07-qclizgf/sos_commands/kubernetes/nodes/kubectl_--kubeconfig_.etc.kubernetes.admin.conf_get_-o_json_node_k8s-worker2: JSON text data

@jcastill
Copy link
Member

jcastill commented Feb 7, 2024

Hi Hervé,

Nice one! But that gives you only the json one. Wouldn't you want both json and 'normal' (i.e. not json) output?

jcastill added a commit to jcastill/sos that referenced this issue Feb 7, 2024
json outputs are easier to parse than the default
output, so lets capture these.

Resolves: sosreport#3484

Co-authored-by: Hervé CHIBOIS

Signed-off-by: Jose Castillo <jcastillo@redhat.com>
@jcastill jcastill linked a pull request Feb 7, 2024 that will close this issue
5 tasks
@jcastill
Copy link
Member

jcastill commented Feb 7, 2024

Hervé, I've created #3509 so we can discuss with the maintainers the next steps directly with code. One of the checks may fail because I've added you as co-author, but I don't have your email, so if you provide it I'll add you there as well.

@hchybz
Copy link
Author

hchybz commented Feb 8, 2024

Fine for the #3509. Yes I think for almost all logs, the "human readable" version aka TEXT and the "machine readable" one aka JSON are interesting. I used to work with EMCgrabs for 10 years and there were no JSON/YAML/XML files .. our new world has thme now, we should be able to use them

maybe I would see yet-another-option in your great tool "kubernetes.output= JSON |TEXT|BOTH"

I have so many other improvments to propose to you... :-)

my mail is herve@chibois.net

jcastill added a commit to jcastill/sos that referenced this issue Feb 8, 2024
json outputs are easier to parse than the default
output, so lets capture these.

Resolves: sosreport#3484

Co-authored-by: Hervé CHIBOIS <herve@chibois.net>

Signed-off-by: Jose Castillo <jcastillo@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants