From: Adam King Date: Thu, 5 Feb 2026 23:10:28 +0000 (-0500) Subject: mgr/cephadm: add __getstate__ so OSD class can be pickled X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=55448804139ce243d6159cc36c4a78761f80ceaf;p=ceph.git mgr/cephadm: add __getstate__ so OSD class can be pickled The OSD class cannot be pickled due to having the `remove_util` field which itself cannot be pickled. ``` 2026-02-05T20:30:15.199 INFO:teuthology.orchestra.run.trial079.stderr:+ ceph orch osd rm status 2026-02-05T20:30:15.199 INFO:teuthology.orchestra.run.trial079.stderr:+ grep '^1' 2026-02-05T20:30:15.356 INFO:teuthology.orchestra.run.trial079.stderr:Error EINVAL: Traceback (most recent call last): 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/mgr_module.py", line 1975, in _handle_command 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: return self.CLICommand.COMMANDS[cmd['prefix']].call(self, cmd, inbuf) # type: ignore[attr-defined] 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/mgr_module.py", line 533, in call 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: return self.func(mgr, **kwargs) 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/orchestrator/cli.py", line 18, in wrapper 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: return func(*args, **kwargs) 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/orchestrator/module.py", line 1612, in _osd_rm_status 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: completion = self.remove_osds_status() 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/orchestrator/_interface.py", line 1840, in inner 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: completion = self._oremote(method_name, args, kwargs) 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/orchestrator/_interface.py", line 1911, in _oremote 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: return mgr.remote(o, meth, *args, **kwargs) 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: File "/usr/share/ceph/mgr/mgr_module.py", line 2559, in remote 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr: return self._ceph_dispatch_remote(module_name, method_name, 2026-02-05T20:30:15.357 INFO:teuthology.orchestra.run.trial079.stderr:RuntimeError: Remote method threw exception: TypeError: cannot pickle 'CephadmOrchestrator' object ``` This commit adds a __getstate__ function which should allow pickle to work around this Fixes: https://tracker.ceph.com/issues/74862 Signed-off-by: Adam King --- diff --git a/src/pybind/mgr/cephadm/services/osd.py b/src/pybind/mgr/cephadm/services/osd.py index 60a399149f9..b22416148a0 100644 --- a/src/pybind/mgr/cephadm/services/osd.py +++ b/src/pybind/mgr/cephadm/services/osd.py @@ -838,6 +838,14 @@ class OSD: def __repr__(self) -> str: return f"osd.{self.osd_id}{' (draining)' if self.draining else ''}" + def __getstate__(self) -> Dict[str, Any]: + # the rm_util field of this class cannot be pickled + # and we should not need it in any case where this class + # has been serialized and deserialized. The from_json function also + # requires an instance of the class to explicitly be passed back in + self.__dict__.update({'remove_util': None}) + return self.__dict__ + class OSDRemovalQueue(object):