Skip to content

Commit

Permalink
Merge branch 'improvement/add-kubectl-top-in-sosreport' into tmp/octo…
Browse files Browse the repository at this point in the history
…pus/w/128.0/improvement/add-kubectl-top-in-sosreport
  • Loading branch information
bert-e committed Apr 16, 2024
2 parents bdddef9 + 99e640d commit e5f99b6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,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

0 comments on commit e5f99b6

Please sign in to comment.