]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: make UpgradeState from_json a bit safer
authorAdam King <adking@redhat.com>
Fri, 1 Apr 2022 12:20:28 +0000 (08:20 -0400)
committerAdam King <adking@redhat.com>
Sat, 21 May 2022 22:06:34 +0000 (18:06 -0400)
This way, for downgrades to whatever versions
this lands in onward, having added new parameters to
UpgradeState shouldn't break anything. Can't do much
about downgrades to older versions from this one
but this should help in the future.

Signed-off-by: Adam King <adking@redhat.com>
(cherry picked from commit aeaa0b5fd87068a31bfa61dd088c49affce42419)

src/pybind/mgr/cephadm/upgrade.py

index cd2aa6cc6d6aaac645abdafaa7bba7ef72b8f06c..70b09be1b9cb9701637124cec7a796571576ab0c 100644 (file)
@@ -86,8 +86,9 @@ class UpgradeState:
 
     @classmethod
     def from_json(cls, data: dict) -> Optional['UpgradeState']:
+        valid_params = UpgradeState.__init__.__code__.co_varnames
         if data:
-            c = {k: v for k, v in data.items()}
+            c = {k: v for k, v in data.items() if k in valid_params}
             if 'repo_digest' in c:
                 c['target_digests'] = [c.pop('repo_digest')]
             return cls(**c)