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

packages/sosreport: Add kubectl top output in MetalK8s plugin #4312

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## Release 127.0.1 (in development)

### Enhancements

- Add `kubectl top` output as part of `metalk8s`
sosreport plugin
(PR[#4312](https://github.com/scality/metalk8s/pull/4312))

### Bug fixes

- In order to reduce slow DNS impact, let's disable
Expand Down
31 changes: 29 additions & 2 deletions packages/common/metalk8s-sosreport/metalk8s.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def _handle_symlinks(src_name, dest_name, kind, namespace=None):
relative_dest = os.path.join(relative_dest, namespace)
_add_symlink(relative_dest, src_path, dest_name)

def _handle_list():
def _handle_global():
for kind, namespaces in ns_kind.items():
for namespace in namespaces:
filename = "{}_ns_{}_list.txt".format(kind, namespace)
Expand All @@ -208,6 +208,23 @@ def _handle_list():
namespace=namespace,
)

if kind == "pod":
filename = "{}_ns_{}_top.txt".format(kind, namespace)
self.add_cmd_output(
"{} top --namespace={} {}".format(
self.kube_cmd, namespace, kind
),
subdir=flat_dir,
suggest_filename=filename,
)

_handle_symlinks(
src_name=filename,
dest_name="top.txt",
kind=kind,
namespace=namespace,
)

for kind in no_ns_kind:
filename = "{}_list.txt".format(kind)
self.add_cmd_output(
Expand All @@ -218,6 +235,16 @@ def _handle_list():

_handle_symlinks(src_name=filename, dest_name="list.txt", kind=kind)

if kind == "node":
filename = "{}_top.txt".format(kind)
self.add_cmd_output(
"{} top {}".format(self.kube_cmd, kind),
subdir=flat_dir,
suggest_filename=filename,
)

_handle_symlinks(src_name=filename, dest_name="top.txt", kind=kind)

def _handle_describe(prefix, obj):
cmd = "{} describe {} {}".format(
self.kube_cmd,
Expand Down Expand Up @@ -368,7 +395,7 @@ def _handle_obj(obj):
for obj in all_no_ns_obj:
_handle_obj(obj)

_handle_list()
_handle_global()

def _setup_metrics(self):
prom_svc = json.loads(
Expand Down
Loading