From 1be63f20f8ef0e593b3f67200137425b69d94128 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 29 Oct 2025 21:02:46 +0000 Subject: [PATCH] python-common/.../service_spec: implement ServiceSpec.__getnewargs__ to allow unpickle to work correctly --- src/python-common/ceph/deployment/service_spec.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/python-common/ceph/deployment/service_spec.py b/src/python-common/ceph/deployment/service_spec.py index b773a17d12c..c985075f268 100644 --- a/src/python-common/ceph/deployment/service_spec.py +++ b/src/python-common/ceph/deployment/service_spec.py @@ -933,6 +933,16 @@ class ServiceSpec(object): sub_cls: Any = cls._cls(service_type) return object.__new__(sub_cls) + + def __getnewargs__(self): + """ + Pickle will pass the return of this function to __new__ upon + unpickle. We need to ensure it gets service_type in order + to get the right subtype. + """ + return (self.service_type,) + + def __init__(self, service_type: str, service_id: Optional[str] = None, -- 2.39.5