From: Neeraj Pratap Singh Date: Tue, 21 Jul 2026 09:56:49 +0000 (+0530) Subject: src/pybind: fixing the test_invalid_client_id failure X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F70375%2Fhead;p=ceph.git src/pybind: fixing the test_invalid_client_id failure The test_invalid_client_id was failing due to the incorrect returns by handle_command and in get_perf_data() in mgr/ststs/fs/perf_stats.py Introduced-by: f8f972182cb1499e0b7686012b0a854f5e76918b Fixes:https://tracker.ceph.com/issues/76162 Signed-off-by: Neeraj Pratap Singh --- diff --git a/src/pybind/mgr/stats/fs/perf_stats.py b/src/pybind/mgr/stats/fs/perf_stats.py index 3c602d2e251e..0ef773722da6 100644 --- a/src/pybind/mgr/stats/fs/perf_stats.py +++ b/src/pybind/mgr/stats/fs/perf_stats.py @@ -639,10 +639,7 @@ class FSPerfStats(object): return FilterSpec(mds_ranks, client_id, client_ip) def get_perf_data(self, cmd): - try: - filter_spec = self.extract_query_filters(cmd) - except ValueError as e: - return -errno.EINVAL, "", str(e) + filter_spec = self.extract_query_filters(cmd) counters = {} with self.lock: diff --git a/src/pybind/mgr/stats/module.py b/src/pybind/mgr/stats/module.py index 119e370a1a63..dd02c2f8c46e 100644 --- a/src/pybind/mgr/stats/module.py +++ b/src/pybind/mgr/stats/module.py @@ -3,6 +3,7 @@ performance stats for ceph filesystem (for now...) """ import json +import errno from typing import List, Dict from xml.dom.minidom import parseString @@ -46,7 +47,11 @@ class Module(MgrModule): prefix = cmd['prefix'] # only supported command is `fs perf stats` right now if prefix.startswith('fs perf stats'): - result = self.fs_perf_stats.get_perf_data(cmd) + try: + result = self.fs_perf_stats.get_perf_data(cmd) + except ValueError as e: + return -errno.EINVAL, "", str(e) + if 'format' in cmd: if cmd['format'] == 'json-pretty': return 0, json.dumps(result, indent=2), "" @@ -54,11 +59,11 @@ class Module(MgrModule): if dicttoxml is None: raise ImportError("dicttoxml package required for xml") result = json.loads(json.dumps(result, default=str)) - return dicttoxml(result) + return 0, dicttoxml(result).decode('utf-8'), "" elif cmd['format'] == 'xml-pretty': if dicttoxml is None: raise ImportError("dicttoxml package required for xml") res_xml = parseString(dicttoxml(result)) - return res_xml.toprettyxml() + return 0, res_xml.toprettyxml(), "" return 0, json.dumps(result), "" raise NotImplementedError(cmd['prefix'])