Skip to content

Commit

Permalink
Merge pull request #11239 from yitzhak12/fix-create-rbd-namespace-com…
Browse files Browse the repository at this point in the history
…mand-param

Fix creating the RBD namespace command with external mode
  • Loading branch information
petr-balogh authored Feb 12, 2025
2 parents cec7026 + 4062d46 commit a003cc5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
12 changes: 9 additions & 3 deletions ocs_ci/deployment/helpers/external_cluster_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,16 @@ def get_external_cluster_details(self):
params = f"{params} --run-as-user {ceph_user}"

if config.EXTERNAL_MODE.get("use_rbd_namespace"):
rbd_namespace = config.EXTERNAL_MODE.get(
"rbd_namespace"
) or self.create_rbd_namespace(rbd=rbd_name)
rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace")
if not rbd_namespace:
rbd_namespace = self.create_rbd_namespace(rbd=rbd_name)
config.EXTERNAL_MODE["rbd_namespace"] = rbd_namespace

params = f"{params} --rados-namespace {rbd_namespace}"
if "restricted-auth-permission" not in params:
params += " --restricted-auth-permission true"
if "cluster-name" not in params:
params += f" --k8s-cluster-name {cluster_name}"

out = self.run_exporter_script(params=params)

Expand Down
5 changes: 4 additions & 1 deletion ocs_ci/helpers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,7 @@ def default_storage_class(
OCS: Existing StorageClass Instance
"""
external = config.DEPLOYMENT["external_mode"]
rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace")
custom_storage_class = config.ENV_DATA.get("custom_default_storageclass_names")
if custom_storage_class:
from ocs_ci.ocs.resources.storage_cluster import (
Expand All @@ -702,7 +703,9 @@ def default_storage_class(
f"StorageCluster spec doesn't have the custom name for '{constants.CEPHBLOCKPOOL}' storageclass"
)
else:
if external:
if rbd_namespace:
resource_name = f"{constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX}-{rbd_namespace}"
elif external:
resource_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD
elif config.ENV_DATA["platform"].lower() in constants.HCI_PC_OR_MS_PLATFORM:
storage_class = OCP(kind="storageclass")
Expand Down
3 changes: 3 additions & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,9 @@
DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_THICK = (
f"{DEFAULT_CLUSTERNAME_EXTERNAL_MODE}-ceph-rbd-thick"
)
DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX = (
f"{DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD}-rados-namespace"
)

# Default StorageClass for Provider-mode
DEFAULT_STORAGECLASS_CLIENT_CEPHFS = f"{DEFAULT_CLUSTERNAME_CLIENT}-cephfs"
Expand Down
9 changes: 6 additions & 3 deletions ocs_ci/ocs/resources/storage_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,9 +464,12 @@ def ocs_install_verification(
)

elif config.DEPLOYMENT["external_mode"]:
sc_rbd = storage_class.get(
resource_name=constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD
)
rbd_namespace = config.EXTERNAL_MODE.get("rbd_namespace")
if rbd_namespace:
rbd_resource_name = f"{constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD_NAMESPACE_PREFIX}-{rbd_namespace}"
else:
rbd_resource_name = constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_RBD
sc_rbd = storage_class.get(resource_name=rbd_resource_name)
sc_cephfs = storage_class.get(
resource_name=(constants.DEFAULT_EXTERNAL_MODE_STORAGECLASS_CEPHFS)
)
Expand Down

0 comments on commit a003cc5

Please sign in to comment.