]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rm nvmeof conf based on its daemon name 60604/head
authorNizamudeen A <nia@redhat.com>
Wed, 23 Oct 2024 15:30:12 +0000 (21:00 +0530)
committerNizamudeen A <nia@redhat.com>
Mon, 4 Nov 2024 07:47:50 +0000 (13:17 +0530)
don't remove an entire entry of a service from the config if only the daemon is
removed, instead just remove the entry of that particular daemon. and
once all the entry are succesfully removed, remove the entry for service

https://tracker.ceph.com/issues/68697
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit 4080115739da4f7ba73a8c0b215aa6b43a34ab71)

 Conflicts:
src/pybind/mgr/cephadm/services/nvmeof.py
 - accepted the current change in squid since gw-groups implementation
   removal looks like missing

src/pybind/mgr/cephadm/services/nvmeof.py
src/pybind/mgr/dashboard/services/nvmeof_cli.py
src/pybind/mgr/dashboard/services/nvmeof_conf.py

index 969c2d14a41dfc8fc0879175ab557a45c3528bbb..78789515a4262c6698f0231ea7a1ddd48ac76f8f 100644 (file)
@@ -143,14 +143,16 @@ class NvmeofService(CephService):
         # to clean the keyring up
         super().post_remove(daemon, is_failed_deploy=is_failed_deploy)
         service_name = daemon.service_name()
+        daemon_name = daemon.name()
 
         # remove config for dashboard nvmeof gateways if any
-        ret, out, err = self.mgr.mon_command({
+        ret, _, err = self.mgr.mon_command({
             'prefix': 'dashboard nvmeof-gateway-rm',
             'name': service_name,
+            'daemon_name': daemon_name
         })
         if not ret:
-            logger.info(f'{daemon.hostname} removed from nvmeof gateways dashboard config')
+            logger.info(f'{daemon_name} removed from nvmeof gateways dashboard config')
 
         # and any certificates being used for mTLS
 
index 11a95237053dbf0214fea94605a8855d0bdfd361..bd9de3504482e1dfc9f13d57087bca84c74352a2 100644 (file)
@@ -36,12 +36,12 @@ def add_nvmeof_gateway(_, inbuf, name: str, group: str, daemon_name: str):
 
 
 @CLIWriteCommand('dashboard nvmeof-gateway-rm')
-def remove_nvmeof_gateway(_, name: str):
+def remove_nvmeof_gateway(_, name: str, daemon_name: str = ''):
     '''
     Remove NVMe-oF gateway configuration
     '''
     try:
-        NvmeofGatewaysConfig.remove_gateway(name)
+        NvmeofGatewaysConfig.remove_gateway(name, daemon_name)
         return 0, 'Success', ''
     except ManagedByOrchestratorException as ex:
         return -errno.EINVAL, '', str(ex)
index 2426c5990787435f0e78d091afcfba82c3286cb4..170f98c70d18f2e69c888b40f32cb1be098381f2 100644 (file)
@@ -77,11 +77,22 @@ class NvmeofGatewaysConfig(object):
         cls._save_config(config)
 
     @classmethod
-    def remove_gateway(cls, name):
+    def remove_gateway(cls, name, daemon_name=None):
         config = cls.get_gateways_config()
         if name not in config['gateways']:
             raise NvmeofGatewayDoesNotExist(name)
-        del config['gateways'][name]
+
+        if not daemon_name:
+            del config['gateways'][name]
+        else:
+            # remove the daemon from the list of gateways
+            config['gateways'][name] = [daemon for daemon in config['gateways'][name]
+                                        if daemon['daemon_name'] != daemon_name]
+
+            # if there are no more daemons in the list, remove the gateway
+            if not config['gateways'][name]:
+                del config['gateways'][name]
+
         cls._save_config(config)
 
     @classmethod