From: Aashish Sharma Date: Mon, 27 Jan 2025 06:14:08 +0000 (+0530) Subject: mgr/dashboard: Multi-site replication wizard breaks when a default realm is already... X-Git-Tag: v20.0.0~213^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c96f8a77e9913a916f9cc1e9d8245990c6515402;p=ceph.git mgr/dashboard: Multi-site replication wizard breaks when a default realm is already present in the secondary cluster. When a default realm is already present in a secondary cluster, the multi-site automation wizard breaks and shows the progress as 0% again. This happens because the last step of the wizard is to confirm the presence of replication user created as a part of the wizard to be present in the secondary cluster and then do the further processing. We fetch the user list from the secondary cluster using get_user_list method which takes the zoneName as input param. In case there is a default realm in the secondary cluster, we need this method to take the realm name as input param as well. Fixes: https://tracker.ceph.com/issues/69670 Signed-off-by: Aashish Sharma --- diff --git a/src/pybind/mgr/dashboard/controllers/rgw.py b/src/pybind/mgr/dashboard/controllers/rgw.py index d48542a7590..4121318dcda 100755 --- a/src/pybind/mgr/dashboard/controllers/rgw.py +++ b/src/pybind/mgr/dashboard/controllers/rgw.py @@ -1294,7 +1294,7 @@ class RgwZone(RESTController): @Endpoint() @ReadPermission - def get_user_list(self, zoneName=None): + def get_user_list(self, zoneName=None, realmName=None): multisite_instance = RgwMultisite() - result = multisite_instance.get_user_list(zoneName) + result = multisite_instance.get_user_list(zoneName, realmName) return result diff --git a/src/pybind/mgr/dashboard/openapi.yaml b/src/pybind/mgr/dashboard/openapi.yaml index de1b3e8b60e..6bae6b857ba 100644 --- a/src/pybind/mgr/dashboard/openapi.yaml +++ b/src/pybind/mgr/dashboard/openapi.yaml @@ -13292,6 +13292,11 @@ paths: name: zoneName schema: type: string + - allowEmptyValue: true + in: query + name: realmName + schema: + type: string responses: '200': content: diff --git a/src/pybind/mgr/dashboard/services/rgw_client.py b/src/pybind/mgr/dashboard/services/rgw_client.py index 9fa249acf44..b17bce8471f 100755 --- a/src/pybind/mgr/dashboard/services/rgw_client.py +++ b/src/pybind/mgr/dashboard/services/rgw_client.py @@ -1290,9 +1290,19 @@ class RgwMultisiteAutomation: path=f'ui-api/rgw/multisite/check-daemons-status?service_name={service_name}', # noqa E501 # pylint: disable=line-too-long token=cluster_token) logger.info("Daemons status: %s", daemons_status) + realms_list = multi_cluster_instance._proxy( + method='GET', + base_url=cluster_url, + path='api/rgw/realm', + token=cluster_token + ) + logger.debug("Realms info in the selected cluster: %s", realms_list) + system_user_param = "realmName" if realms_list.get('default_info') \ + else "zoneName" if daemons_status is True: self.check_user_in_second_cluster(cluster_url, cluster_token, - username, replication_zone_name) + username, replication_zone_name, + system_user_param, realm_name) else: self.update_progress("Failed to set credentials in selected cluster", 'fail', "RGW daemons failed to start") # noqa E501 # pylint: disable=line-too-long return token_import_response @@ -1310,9 +1320,17 @@ class RgwMultisiteAutomation: raise def check_user_in_second_cluster(self, cluster_url, cluster_token, username, - replication_zone_name): + replication_zone_name, system_user_param, + realm_name): logger.info("Checking for user %s in the second cluster", username) - path = f'api/rgw/zone/get_user_list?zoneName={replication_zone_name}' + params = { + "zoneName": f"zoneName={replication_zone_name}", + "realmName": f"realmName={realm_name}", + } + if system_user_param in params: + path = f"api/rgw/zone/get_user_list?{params[system_user_param]}" + else: + raise ValueError(f"Invalid system_user_param: {system_user_param}") user_found = False start_time = time.time() while not user_found: @@ -1327,6 +1345,7 @@ class RgwMultisiteAutomation: # pylint: disable=protected-access user_content = multi_cluster_instance._proxy(method='GET', base_url=cluster_url, path=path, token=cluster_token) + logger.debug("user_content in selected cluster: %s", user_content) if isinstance(user_content, list) and username in user_content: user_found = True logger.info("User %s found in the second cluster", username) @@ -1991,9 +2010,12 @@ class RgwMultisite: except SubprocessError as error: raise DashboardException(error, http_status_code=500, component='rgw') - def get_user_list(self, zoneName: str): + def get_user_list(self, zoneName=None, realmName=None): user_list = [] - rgw_user_list_cmd = ['user', 'list', '--rgw-zone', zoneName] + if zoneName: + rgw_user_list_cmd = ['user', 'list', '--rgw-zone', zoneName] + if realmName: + rgw_user_list_cmd = ['user', 'list', '--rgw-realm', realmName] try: exit_code, out, _ = mgr.send_rgwadmin_command(rgw_user_list_cmd) if exit_code > 0: