Skip to content

Commit

Permalink
Added check for ns availability before creation
Browse files Browse the repository at this point in the history
Signed-off-by: Amrita Mahapatra <[email protected]>
  • Loading branch information
amr1ta committed Jun 5, 2024
1 parent 4957867 commit cee703e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
11 changes: 9 additions & 2 deletions ocs_ci/deployment/provider_client/storage_client_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ def initial_function(self):
login_ui()
self.validation_ui_obj = ValidationUI()
self.ns_obj = ocp.OCP(kind=constants.NAMESPACES)
self.ns_obj.new_project(
project_name=constants.BM_DEBUG_NODE_NS, policy=constants.PSA_PRIVILEGED

# Check constants.BM_DEBUG_NODE_NS is available or not
is_available = self.ns_obj.is_exist(
resource_name=constants.BM_DEBUG_NODE_NS,
)

if not is_available:
self.ns_obj.new_project(
project_name=constants.BM_DEBUG_NODE_NS, policy=constants.PSA_PRIVILEGED
)
self.ocp_obj = ocp.OCP()
self.storage_cluster_obj = ocp.OCP(
kind="Storagecluster", namespace=config.ENV_DATA["cluster_namespace"]
Expand Down
1 change: 1 addition & 0 deletions ocs_ci/helpers/managed_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ def get_all_storageclassclaims(namespace=None):
else:
sc_claim_obj = OCP(kind=constants.STORAGECLASSCLAIM, namespace=namespace)
sc_claims_data = sc_claim_obj.get()["items"]
log.info(f"storage claims: {sc_claims_data}")
return [OCS(**claim_data) for claim_data in sc_claims_data]


Expand Down
17 changes: 13 additions & 4 deletions ocs_ci/ocs/resources/storage_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,15 @@ def create_storageclaim(
)
self.ocp_obj.exec_oc_cmd(f"apply -f {storage_classclaim_data_yaml.name}")

# def fetch_storageclaims(
# self,
# namespace=None,

# ):
# """

# """

def verify_storage_claim_status(
self,
storageclient_name=None,
Expand All @@ -304,7 +313,6 @@ def verify_storage_claim_status(
if not namespace:
namespace = config.ENV_DATA["cluster_namespace"]
sc_claims = get_all_storageclassclaims()
log.info(f"storage claims are {sc_claims}")
for sc_claim in sc_claims:
if self.ocs_version >= version.VERSION_4_16:
if sc_claim.data["spec"]["storageClient"] == storageclient_name:
Expand Down Expand Up @@ -333,7 +341,7 @@ def verify_storagerequest_exists(
"""
cmd = f"get storagerequests -n {namespace} " "-o=jsonpath='{.items[*]}'"
storage_requests = self.ocp_obj.exec_oc_cmd(command=cmd, out_yaml_format=True)
storage_requests = self.ocp_obj.exec_oc_cmd(command=cmd, out_yaml_format=False)

log.info(f"The list of storagerequests: {storage_requests}")
return (
Expand Down Expand Up @@ -494,8 +502,9 @@ def verify_native_storageclient(self):
kind=constants.STORAGECLIENT,
namespace=namespace,
)
storageclient = storageclient_obj.get()["items"][0]
storageclient_name = storageclient["metadata"]["name"]
storageclient_data = storageclient_obj.get()["items"]
log.info(f"storageclient data, {storageclient_data[0]}")
storageclient_name = storageclient_data[0]["metadata"]["name"]

# Verify storageclient is in Connected status
self.verify_storageclient_status(
Expand Down

0 comments on commit cee703e

Please sign in to comment.