Skip to content

Commit c96f8a7

Browse files
author
Aashish Sharma
committed
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 <[email protected]>
1 parent 54b4067 commit c96f8a7

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

src/pybind/mgr/dashboard/controllers/rgw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,7 @@ def create_system_user(self, userName: str, zoneName: str):
12941294

12951295
@Endpoint()
12961296
@ReadPermission
1297-
def get_user_list(self, zoneName=None):
1297+
def get_user_list(self, zoneName=None, realmName=None):
12981298
multisite_instance = RgwMultisite()
1299-
result = multisite_instance.get_user_list(zoneName)
1299+
result = multisite_instance.get_user_list(zoneName, realmName)
13001300
return result

src/pybind/mgr/dashboard/openapi.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13292,6 +13292,11 @@ paths:
1329213292
name: zoneName
1329313293
schema:
1329413294
type: string
13295+
- allowEmptyValue: true
13296+
in: query
13297+
name: realmName
13298+
schema:
13299+
type: string
1329513300
responses:
1329613301
'200':
1329713302
content:

src/pybind/mgr/dashboard/services/rgw_client.py

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,9 +1290,19 @@ def import_realm_token_to_cluster(self, cluster_fsid, realm_name, zonegroup_name
12901290
path=f'ui-api/rgw/multisite/check-daemons-status?service_name={service_name}', # noqa E501 # pylint: disable=line-too-long
12911291
token=cluster_token)
12921292
logger.info("Daemons status: %s", daemons_status)
1293+
realms_list = multi_cluster_instance._proxy(
1294+
method='GET',
1295+
base_url=cluster_url,
1296+
path='api/rgw/realm',
1297+
token=cluster_token
1298+
)
1299+
logger.debug("Realms info in the selected cluster: %s", realms_list)
1300+
system_user_param = "realmName" if realms_list.get('default_info') \
1301+
else "zoneName"
12931302
if daemons_status is True:
12941303
self.check_user_in_second_cluster(cluster_url, cluster_token,
1295-
username, replication_zone_name)
1304+
username, replication_zone_name,
1305+
system_user_param, realm_name)
12961306
else:
12971307
self.update_progress("Failed to set credentials in selected cluster", 'fail', "RGW daemons failed to start") # noqa E501 # pylint: disable=line-too-long
12981308
return token_import_response
@@ -1310,9 +1320,17 @@ def import_realm_token_to_cluster(self, cluster_fsid, realm_name, zonegroup_name
13101320
raise
13111321

13121322
def check_user_in_second_cluster(self, cluster_url, cluster_token, username,
1313-
replication_zone_name):
1323+
replication_zone_name, system_user_param,
1324+
realm_name):
13141325
logger.info("Checking for user %s in the second cluster", username)
1315-
path = f'api/rgw/zone/get_user_list?zoneName={replication_zone_name}'
1326+
params = {
1327+
"zoneName": f"zoneName={replication_zone_name}",
1328+
"realmName": f"realmName={realm_name}",
1329+
}
1330+
if system_user_param in params:
1331+
path = f"api/rgw/zone/get_user_list?{params[system_user_param]}"
1332+
else:
1333+
raise ValueError(f"Invalid system_user_param: {system_user_param}")
13161334
user_found = False
13171335
start_time = time.time()
13181336
while not user_found:
@@ -1327,6 +1345,7 @@ def check_user_in_second_cluster(self, cluster_url, cluster_token, username,
13271345
# pylint: disable=protected-access
13281346
user_content = multi_cluster_instance._proxy(method='GET', base_url=cluster_url,
13291347
path=path, token=cluster_token)
1348+
logger.debug("user_content in selected cluster: %s", user_content)
13301349
if isinstance(user_content, list) and username in user_content:
13311350
user_found = True
13321351
logger.info("User %s found in the second cluster", username)
@@ -1991,9 +2010,12 @@ def create_system_user(self, userName: str, zoneName: str):
19912010
except SubprocessError as error:
19922011
raise DashboardException(error, http_status_code=500, component='rgw')
19932012

1994-
def get_user_list(self, zoneName: str):
2013+
def get_user_list(self, zoneName=None, realmName=None):
19952014
user_list = []
1996-
rgw_user_list_cmd = ['user', 'list', '--rgw-zone', zoneName]
2015+
if zoneName:
2016+
rgw_user_list_cmd = ['user', 'list', '--rgw-zone', zoneName]
2017+
if realmName:
2018+
rgw_user_list_cmd = ['user', 'list', '--rgw-realm', realmName]
19972019
try:
19982020
exit_code, out, _ = mgr.send_rgwadmin_command(rgw_user_list_cmd)
19992021
if exit_code > 0:

0 commit comments

Comments
 (0)