]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/cephadm: stop using "self.gws" in nvmeof service class
authorAdam King <adking@redhat.com>
Wed, 26 Jun 2024 14:28:49 +0000 (10:28 -0400)
committerAlexander Indenbaum <aindenba@redhat.com>
Thu, 20 Nov 2025 08:55:27 +0000 (10:55 +0200)
Using some "self.<attr>" in this class for anything that isn't constant
doesn't work. For one, on any restart of the cephadm mgr module,
including on mgr failover, upgrade, etc. will cause this attribute to
be lost. Furthermore, this makes the class unable to handle multiple
nvmeof services. If you had multiple services before this patch
and then removed one of them, assuming "self.gws" hasn't already
been dropped due to the cephadm module restarting, it would
cause ALL nvmeof daemons in the cluster to be run through the
"nvme-gw delete" command, not just the ones tied to the service
being removed. The most sane way to handle this removal imo is
to do so when the daemon is being removed. The extra attempt to
run all the nvmeof daemons through "nvme-gw delete" when purging
the service is unnecessary and complicates the process. We
should rely on this happening in "post_remove" which handles
it for individual daemons and if that doesn't work we should
fix it rather than trying to just do it again when removing
the service.

Resolves: rhbz#2294382

Signed-off-by: Adam King <adking@redhat.com>
src/pybind/mgr/cephadm/services/nvmeof.py

index ce231a798448d052a8596667e3844189744f8766..76441ef06d928fabe9d4da2b1f38b5b9b7673d31 100644 (file)
@@ -84,9 +84,6 @@ class NvmeofService(CephService):
 
         daemon_spec.final_config, daemon_spec.deps = self.generate_config(daemon_spec)
         daemon_spec.deps = []
-        if not hasattr(self, 'gws'):
-            self.gws = {} # id -> name map of gateways for this service.
-        self.gws[nvmeof_gw_id] = name # add to map of service's gateway names
         return daemon_spec
 
     def daemon_check_post(self, daemon_descrs: List[DaemonDescription]) -> None:
@@ -101,17 +98,10 @@ class NvmeofService(CephService):
         pool = spec.pool
         group = spec.group
         for dd in daemon_descrs:
-            self.mgr.log.info(f"nvmeof daemon_descr {dd}")
-            if dd.daemon_id not in self.gws:
-                err_msg = ('Trying to daemon_check_post nvmeof but daemon_id is unknown')
-                logger.error(err_msg)
-                raise OrchestratorError(err_msg)
-            name = self.gws[dd.daemon_id]
-            self.mgr.log.info(f"nvmeof daemon name={name}")
             # Notify monitor about this gateway creation
             cmd = {
                 'prefix': 'nvme-gw create',
-                'id': name,
+                'id': dd.daemon_id,
                 'group': group,
                 'pool': pool
             }
@@ -204,17 +194,10 @@ class NvmeofService(CephService):
         pool = spec.pool
         group = spec.group
 
-        if daemon.daemon_id not in self.gws:
-            err_msg = (f'Trying to remove nvmeof but {daemon.daemon_id} '
-                       'not in gws list')
-            logger.error(err_msg)
-            raise OrchestratorError(err_msg)
-        name = self.gws[daemon.daemon_id]
-        self.gws.pop(daemon.daemon_id)
         # Notify monitor about this gateway deletion
         cmd = {
             'prefix': 'nvme-gw delete',
-            'id': name,
+            'id': daemon.daemon_id,
             'group': group,
             'pool': pool
         }
@@ -222,30 +205,3 @@ class NvmeofService(CephService):
         _, _, err = self.mgr.mon_command(cmd)
         if err:
             self.mgr.log.error(f"Unable to send monitor command {cmd}, error {err}")
-
-    def purge(self, service_name: str) -> None:
-        """Make sure no zombie gateway is left behind
-        """
-        # Assert configured
-        spec = cast(NvmeofServiceSpec, self.mgr.spec_store.all_specs.get(service_name, None))
-        if not spec:
-            self.mgr.log.error(f'Failed to find spec for {service_name}')
-            return
-        pool = spec.pool
-        group = spec.group
-        for daemon_id in self.gws:
-            name = self.gws[daemon_id]
-            self.gws.pop(daemon_id)
-            # Notify monitor about this gateway deletion
-            cmd = {
-                'prefix': 'nvme-gw delete',
-                'id': name,
-                'group': group,
-                'pool': pool
-            }
-            self.mgr.log.info(f"purge delete gateway: monitor command {cmd}")
-            _, _, err = self.mgr.mon_command(cmd)
-            if err:
-                err_msg = (f'Monitor command "{cmd}" failed: {err}')
-                logger.error(err_msg)
-                raise OrchestratorError(err_msg)