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
# 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
@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)
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