Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
31 changes: 27 additions & 4 deletions ocs_ci/helpers/dr_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
find_cephblockpoolradosnamespace,
find_cephfilesystemsubvolumegroup,
create_unique_resource_name,
find_radosnamespace,
)
from ocs_ci.helpers import helpers

Expand Down Expand Up @@ -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]
Comment thread
jilju marked this conversation as resolved.
Comment thread
jilju marked this conversation as resolved.

logger.info(f"Got cephblockpoolradosnamespace {cephbpradosns}")

Expand All @@ -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"],
Expand Down Expand Up @@ -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:
Expand Down
48 changes: 46 additions & 2 deletions ocs_ci/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Comment thread
jilju marked this conversation as resolved.
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
Expand Down Expand Up @@ -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.
Expand Down
Loading