]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: verify mon spec exists before trying to grab from spec store 51217/head
authorAdam King <adking@redhat.com>
Tue, 2 May 2023 22:59:18 +0000 (18:59 -0400)
committerAdam King <adking@redhat.com>
Wed, 24 May 2023 17:34:44 +0000 (13:34 -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 efce19f027b5b7b583c561ecd7cf60cf2edc128d..10153882ee458a5f3d31889afd2d079158d237c5 100644 (file)
@@ -652,15 +652,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