diff --git a/CHANGELOG.md b/CHANGELOG.md index df07ee8b2c..c5d5e7825d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/packages/common/metalk8s-sosreport/metalk8s.py b/packages/common/metalk8s-sosreport/metalk8s.py index 47d5074601..ad53d99a31 100644 --- a/packages/common/metalk8s-sosreport/metalk8s.py +++ b/packages/common/metalk8s-sosreport/metalk8s.py @@ -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) @@ -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( @@ -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, @@ -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(