diff --git a/.secrets.baseline b/.secrets.baseline index 5244e5b222c..12704bf7935 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -597,7 +597,7 @@ "hashed_secret": "66a36e77fd002579809717841f998f4d21cd5913", "is_secret": false, "is_verified": false, - "line_number": 2931, + "line_number": 2896, "type": "Secret Keyword", "verified_result": null } diff --git a/ocs_ci/helpers/dr_helpers.py b/ocs_ci/helpers/dr_helpers.py index 81c7feaffb5..75d5c275275 100644 --- a/ocs_ci/helpers/dr_helpers.py +++ b/ocs_ci/helpers/dr_helpers.py @@ -65,6 +65,7 @@ find_cephblockpoolradosnamespace, find_cephfilesystemsubvolumegroup, create_unique_resource_name, + find_radosnamespace, ) from ocs_ci.helpers import helpers @@ -420,8 +421,20 @@ def check_mirroring_status_ok( if not cephbpradosns: raise NotFoundError("Couldn't identify the cephblockpoolradosnamespace") - if "ocs-storagecluster-cephblockpool" not in cephbpradosns: - cephbpradosns = "ocs-storagecluster-cephblockpool-" + cephbpradosns + if ( + "ocs-storagecluster-cephblockpool" not in cephbpradosns + and "replicated-metadata-pool" not in cephbpradosns + ): + cephblockpool_rns_names = [ + cephbprns_data["metadata"]["name"] + for cephbprns_data in ocp.OCP( + kind=constants.CEPHBLOCKPOOLRADOSNS, + namespace=config.ENV_DATA["cluster_namespace"], + ).get()["items"] + ] + cephbpradosns = list( + filter(lambda x: f"-{cephbpradosns}" in x, cephblockpool_rns_names) + )[0] logger.info(f"Got cephblockpoolradosnamespace {cephbpradosns}") @@ -434,7 +447,17 @@ def check_mirroring_status_ok( ) else: if ocs_version >= version.VERSION_4_19: - cephbpradosns = "ocs-storagecluster-cephblockpool-builtin-implicit" + # The name of builtin-implicit cephblockpoolradosnamespace is different in EC cluster and non EC cluster + cephblockpool_rns_names = [ + cephbprns_data["metadata"]["name"] + for cephbprns_data in ocp.OCP( + kind=constants.CEPHBLOCKPOOLRADOSNS, + namespace=config.ENV_DATA["cluster_namespace"], + ).get()["items"] + ] + cephbpradosns = list( + filter(lambda x: "-builtin-implicit" in x, cephblockpool_rns_names) + )[0] cbp_obj = ocp.OCP( kind=constants.CEPHBLOCKPOOLRADOSNS, namespace=config.ENV_DATA["cluster_namespace"], @@ -1378,7 +1401,7 @@ def verify_backend_volume_deletion( cephbpradosns = ( cephblockpoolradosns or config.ENV_DATA.get("radosnamespace_name", None) - or find_cephblockpoolradosnamespace(storageclient_uid=storageclient_uid) + or find_radosnamespace(storageclient_uid=storageclient_uid) ) if not cephbpradosns: diff --git a/ocs_ci/helpers/helpers.py b/ocs_ci/helpers/helpers.py index e559cfc243c..f60e5f8d5bf 100644 --- a/ocs_ci/helpers/helpers.py +++ b/ocs_ci/helpers/helpers.py @@ -6962,13 +6962,32 @@ def find_cephblockpoolradosnamespace(storageclient_uid=None): for storageconsumer_dict in storageconsumer_obj.get()["items"]: if storageconsumer_dict["status"]["client"]["clientId"] == storageclient_uid: storageconsumer = storageconsumer_dict["metadata"]["name"] + # TODO: Use configmap with name storageconsumer_dict["status"]["resourceNameMappingConfigMap"]["name"] to + # identify the radosnamespace and then use it to find the cephblockpoolradosnamespace CR. This is not + # applicable for internal storageconsumer because the configmap will not have the exact name of + # radosnamespace break + + with config.RunWithProviderConfigContextIfAvailable(): + cephblockpool_rns_names = [ + cephbprns_data["metadata"]["name"] + for cephbprns_data in ocp.OCP( + kind=constants.CEPHBLOCKPOOLRADOSNS, + namespace=config.ENV_DATA["cluster_namespace"], + ).get()["items"] + ] + if storageconsumer == constants.INTERNAL_STORAGE_CONSUMER_NAME: + cephbpradosns = list( + filter(lambda x: "-builtin-implicit" in x, cephblockpool_rns_names) + )[0] + else: + cephbpradosns = list( + filter(lambda x: f"-{storageconsumer}" in x, cephblockpool_rns_names) + )[0] logger.info( f"StorageClient is {storageclient_name} with uid {storageclient_uid}. StorageConsumer is {storageconsumer}" ) - cephbpradosns = storageconsumer - # from ODF 4.19 and onwards, StorageRequest does not exist on new clusters, upgraded clusters have it, # but StorageRequest is not reconciled. StorageConsumer exists in storage hub cluster and in consumer clusters # to make this function generic need to switch context between clusters @@ -7056,6 +7075,31 @@ def find_cephfilesystemsubvolumegroup(storageclient_uid=None): return cephbfssubvolumegroup +def find_radosnamespace(storageclient_uid=None): + """ + Find the radosnamespace related to a storageclient if present + + Args: + storageclient_id(string): The uid of the storageclient for which the lradosnamespace has to be identified + + Returns: + str: The name of the radosnamespace, if present + + """ + cephblockpoolradosnamespace = find_cephblockpoolradosnamespace( + storageclient_uid=storageclient_uid + ) + if "-builtin-implicit" not in cephblockpoolradosnamespace: + with config.RunWithProviderConfigContextIfAvailable(): + cbp_rns = ocp.OCP( + kind=constants.CEPHBLOCKPOOLRADOSNS, + namespace=config.ENV_DATA["cluster_namespace"], + resource_name=cephblockpoolradosnamespace, + ) + radosnamespace = cbp_rns.get()["spec"]["name"] + return radosnamespace + + def remove_port_from_url(url): """ Remove the port from a URL while preserving the scheme, hostname, and path.