From 215ad503b427ea51518134e3984f42ab9b927f7a Mon Sep 17 00:00:00 2001 From: Ricardo Marques Date: Thu, 30 Jan 2020 13:19:48 +0000 Subject: [PATCH] mgr/dashboard: Unable to remove an iSCSI gateway that is already in use Fixes: https://tracker.ceph.com/issues/43900 Signed-off-by: Ricardo Marques (cherry picked from commit bcb05d0cae89deeb6c5e6a0cf282d84fed7811c3) --- src/pybind/mgr/dashboard/controllers/iscsi.py | 3 ++- src/pybind/mgr/dashboard/services/iscsi_cli.py | 10 +--------- src/pybind/mgr/dashboard/services/iscsi_config.py | 6 ------ 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/iscsi.py b/src/pybind/mgr/dashboard/controllers/iscsi.py index 93189685d73aa..843b0fac0b3a8 100644 --- a/src/pybind/mgr/dashboard/controllers/iscsi.py +++ b/src/pybind/mgr/dashboard/controllers/iscsi.py @@ -16,6 +16,7 @@ from ..rest_client import RequestException from ..security import Scope from ..services.iscsi_client import IscsiClient from ..services.iscsi_cli import IscsiGatewaysConfig +from ..services.iscsi_config import IscsiGatewayDoesNotExist from ..services.rbd import format_bitmask from ..services.tcmu_service import TcmuService from ..exceptions import DashboardException @@ -848,7 +849,7 @@ class IscsiTarget(RESTController): for portal in target['portals']: try: IscsiClient.instance(gateway_name=portal['host']).ping() - except RequestException: + except (IscsiGatewayDoesNotExist, RequestException): return gateway_name = target['portals'][0]['host'] try: diff --git a/src/pybind/mgr/dashboard/services/iscsi_cli.py b/src/pybind/mgr/dashboard/services/iscsi_cli.py index d7a0a0139cd9a..fca1f61b3cc14 100644 --- a/src/pybind/mgr/dashboard/services/iscsi_cli.py +++ b/src/pybind/mgr/dashboard/services/iscsi_cli.py @@ -8,7 +8,7 @@ from mgr_module import CLIReadCommand, CLIWriteCommand from .iscsi_client import IscsiClient from .iscsi_config import IscsiGatewaysConfig, IscsiGatewayAlreadyExists, InvalidServiceUrl, \ - ManagedByOrchestratorException, IscsiGatewayDoesNotExist, IscsiGatewayInUse + ManagedByOrchestratorException, IscsiGatewayDoesNotExist from ..rest_client import RequestException @@ -41,16 +41,8 @@ def add_iscsi_gateway(_, service_url): 'Remove iSCSI gateway configuration') def remove_iscsi_gateway(_, name): try: - try: - iscsi_config = IscsiClient.instance(gateway_name=name).get_config() - if name in iscsi_config['gateways']: - raise IscsiGatewayInUse(name) - except RequestException: - pass IscsiGatewaysConfig.remove_gateway(name) return 0, 'Success', '' - except IscsiGatewayInUse as ex: - return -errno.EBUSY, '', str(ex) except IscsiGatewayDoesNotExist as ex: return -errno.ENOENT, '', str(ex) except ManagedByOrchestratorException as ex: diff --git a/src/pybind/mgr/dashboard/services/iscsi_config.py b/src/pybind/mgr/dashboard/services/iscsi_config.py index c8cded19ab043..2f119136e1bd5 100644 --- a/src/pybind/mgr/dashboard/services/iscsi_config.py +++ b/src/pybind/mgr/dashboard/services/iscsi_config.py @@ -27,12 +27,6 @@ class IscsiGatewayDoesNotExist(Exception): "iSCSI gateway '{}' does not exist".format(hostname)) -class IscsiGatewayInUse(Exception): - def __init__(self, hostname): - super(IscsiGatewayInUse, self).__init__( - "iSCSI gateway '{}' is in use".format(hostname)) - - class InvalidServiceUrl(Exception): def __init__(self, service_url): super(InvalidServiceUrl, self).__init__( -- 2.39.5