]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Multi-site replication wizard breaks when a default realm is already... 61534/head
authorAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Mon, 27 Jan 2025 06:14:08 +0000 (11:44 +0530)
committerAashish Sharma <aasharma@li-e74156cc-2f67-11b2-a85c-e98659a63c5c.ibm.com>
Thu, 30 Jan 2025 09:32:15 +0000 (15:02 +0530)
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 <aasharma@redhat.com>
src/pybind/mgr/dashboard/controllers/rgw.py
src/pybind/mgr/dashboard/openapi.yaml
src/pybind/mgr/dashboard/services/rgw_client.py

index d48542a7590387555b12441f0c5312e632c8f5e4..4121318dcda133d7169ef822e6808119415ed50d 100755 (executable)
@@ -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
index de1b3e8b60e29eef8c3cf9c5c6c6da1d1f68557f..6bae6b857badeef0d61175ccc608a7bc20b6b5c0 100644 (file)
@@ -13292,6 +13292,11 @@ paths:
         name: zoneName
         schema:
           type: string
+      - allowEmptyValue: true
+        in: query
+        name: realmName
+        schema:
+          type: string
       responses:
         '200':
           content:
index 9fa249acf444e030004ce2bdc4a1e0f52d7cb93c..b17bce8471fd810fe4eac7ebdb5e3708078d195c 100755 (executable)
@@ -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: