]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: verify mon spec exists before trying to grab from spec store 51612/head
authorAdam King <adking@redhat.com>
Tue, 2 May 2023 22:59:18 +0000 (18:59 -0400)
committerAdam King <adking@redhat.com>
Sun, 21 May 2023 19:56:27 +0000 (15:56 -0400)
In a normal deployment, we generally shouldn't have
to worry about this. This is more for teuthology
which does deployments in a weird way that can cause
there to be no mon spec in the cluster. Fixes an issue
seen when backporting the mon crush location work
to quincy where an upgrade test would fail with

```
[WRN] UPGRADE_REDEPLOY_DAEMON: Upgrading daemon mon.b on host smithi047 failed.
    Upgrade daemon: mon.b: Service mon not found.
```

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

src/pybind/mgr/cephadm/services/cephadmservice.py

index 9272bccdd9f1c00c25e82dab57fa6f72ecc38752..d79ed2a28988e60e7a8295b8a534f97e681b919b 100644 (file)
@@ -651,15 +651,20 @@ class MonService(CephService):
     def generate_config(self, daemon_spec: CephadmDaemonDeploySpec) -> Tuple[Dict[str, Any], List[str]]:
         daemon_spec.final_config, daemon_spec.deps = super().generate_config(daemon_spec)
 
-        mon_spec = cast(MONSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
-        if mon_spec.crush_locations:
-            if daemon_spec.host in mon_spec.crush_locations:
-                # the --crush-location flag only supports a single bucket=loc pair so
-                # others will have to be handled later. The idea is to set the flag
-                # for the first bucket=loc pair in the list in order to facilitate
-                # replacing a tiebreaker mon (https://docs.ceph.com/en/quincy/rados/operations/stretch-mode/#other-commands)
-                c_loc = mon_spec.crush_locations[daemon_spec.host][0]
-                daemon_spec.final_config['crush_location'] = c_loc
+        # realistically, we expect there to always be a mon spec
+        # in a real deployment, but the way teuthology deploys some daemons
+        # it's possible there might not be. For that reason we need to
+        # verify the service is present in the spec store.
+        if daemon_spec.service_name in self.mgr.spec_store:
+            mon_spec = cast(MONSpec, self.mgr.spec_store[daemon_spec.service_name].spec)
+            if mon_spec.crush_locations:
+                if daemon_spec.host in mon_spec.crush_locations:
+                    # the --crush-location flag only supports a single bucket=loc pair so
+                    # others will have to be handled later. The idea is to set the flag
+                    # for the first bucket=loc pair in the list in order to facilitate
+                    # replacing a tiebreaker mon (https://docs.ceph.com/en/quincy/rados/operations/stretch-mode/#other-commands)
+                    c_loc = mon_spec.crush_locations[daemon_spec.host][0]
+                    daemon_spec.final_config['crush_location'] = c_loc
 
         return daemon_spec.final_config, daemon_spec.deps