]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: add __getstate__ so OSD class can be pickled 67236/head
authorAdam King <adking@redhat.com>
Thu, 5 Feb 2026 23:10:28 +0000 (18:10 -0500)
committerAdam King <adking@redhat.com>
Tue, 10 Feb 2026 20:59:00 +0000 (15:59 -0500)
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 <adking@redhat.com>
src/pybind/mgr/cephadm/services/osd.py

index 60a399149f9f9377ef77b34409f50ef656bdb9a8..b22416148a04ef00ddb64d02f21c8f8a35572500 100644 (file)
@@ -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):