From: Nitzan Mordechai Date: Wed, 27 Aug 2025 10:49:40 +0000 (+0000) Subject: mgr/insights: fix read-only copy before change X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2d5dd7a9e1eae39c85d1598824338d2d0729190f;p=ceph.git mgr/insights: fix read-only copy before change since we are modifying read-only python object, we need to copy it first Fixes: https://tracker.ceph.com/issues/72447 Signed-off-by: Nitzan Mordechai --- diff --git a/src/pybind/mgr/insights/health.py b/src/pybind/mgr/insights/health.py index 1deb5d3a611..8647c8b71eb 100644 --- a/src/pybind/mgr/insights/health.py +++ b/src/pybind/mgr/insights/health.py @@ -12,7 +12,9 @@ NOW_OFFSET = None class HealthEncoder(json.JSONEncoder): def default(self, obj): - if isinstance(obj, set): + if obj.__class__.__name__ == 'mappingproxy': + return dict(obj) + elif isinstance(obj, set): return list(obj) return json.JSONEncoder.default(self, obj) diff --git a/src/pybind/mgr/insights/module.py b/src/pybind/mgr/insights/module.py index 6e8c6aa7d12..1301930e8a7 100644 --- a/src/pybind/mgr/insights/module.py +++ b/src/pybind/mgr/insights/module.py @@ -273,8 +273,8 @@ class Module(MgrModule): report["config"] = config health_check_details.extend(health_details) - osd_map = self.get("osd_map") - del osd_map['pg_temp'] + osd_map = self.get("osd_map", mutable=True) + osd_map.pop("pg_temp", None) self._apply_osd_stats(osd_map) report["osd_dump"] = osd_map