From 6e530e8eb19d7d161db27a1f9cbfc17b04e6635e Mon Sep 17 00:00:00 2001 From: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> Date: Tue, 4 Jun 2024 12:32:11 +0530 Subject: [PATCH] Updated local storage option operator image details Signed-off-by: Amrita Mahapatra <49347640+amr1ta@users.noreply.github.com> --- ocs_ci/helpers/managed_services.py | 27 ++++++++-------- ocs_ci/ocs/resources/storage_client.py | 32 +++++++++++-------- .../local-storage-optional-operators.yaml | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/ocs_ci/helpers/managed_services.py b/ocs_ci/helpers/managed_services.py index 56c4411253b..cec807697a6 100644 --- a/ocs_ci/helpers/managed_services.py +++ b/ocs_ci/helpers/managed_services.py @@ -299,15 +299,17 @@ def get_storageclassclaims_of_storageclient(storageclient_name): List: OCS objects of kind Storageclassclaim """ + ocs_version = version.get_semantic_ocs_version_from_config() sc_claims = get_all_storageclassclaims() - return [ - sc_claim - for sc_claim in sc_claims - if sc_claim.data["spec"]["storageClient"]["name"] == storageclient_name - ] + for sc_claim in sc_claims: + if ocs_version >= version.VERSION_4_16: + sc_claim.data["spec"]["storageClient"] == storageclient_name + else: + sc_claim.data["spec"]["storageClient"]["name"] == storageclient_name + return sc_claim -def get_all_storageclassclaims(): +def get_all_storageclassclaims(namespace=None): """ Get all storageclassclaims @@ -315,16 +317,14 @@ def get_all_storageclassclaims(): List: OCS objects of kind Storageclassclaim """ + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] + ocs_version = version.get_semantic_ocs_version_from_config() if ocs_version >= version.VERSION_4_16: - sc_claim_obj = OCP( - kind=constants.STORAGECLAIM, namespace=config.ENV_DATA["cluster_namespace"] - ) + sc_claim_obj = OCP(kind=constants.STORAGECLAIM, namespace=namespace) else: - sc_claim_obj = OCP( - kind=constants.STORAGECLASSCLAIM, - namespace=config.ENV_DATA["cluster_namespace"], - ) + sc_claim_obj = OCP(kind=constants.STORAGECLASSCLAIM, namespace=namespace) sc_claims_data = sc_claim_obj.get()["items"] return [OCS(**claim_data) for claim_data in sc_claims_data] @@ -338,6 +338,7 @@ def verify_storageclient_storageclass_claims(storageclient): """ sc_claim_objs = get_storageclassclaims_of_storageclient(storageclient) + log.info(f"storageclaims: {sc_claim_objs}") # Wait for the storageclassclaims to be in Ready state for sc_claim in sc_claim_objs: diff --git a/ocs_ci/ocs/resources/storage_client.py b/ocs_ci/ocs/resources/storage_client.py index 852284c852b..d76a9e75b22 100644 --- a/ocs_ci/ocs/resources/storage_client.py +++ b/ocs_ci/ocs/resources/storage_client.py @@ -166,9 +166,7 @@ def create_storage_client( log.info("Creating storageclient CR") self.ocp_obj.exec_oc_cmd(f"apply -f {storage_client_data_yaml.name}") - def fetch_storage_client_status( - self, namespace=config.ENV_DATA["cluster_namespace"], storageclient_name=None - ): + def fetch_storage_client_status(self, namespace=None, storageclient_name=None): """ Fetch storageclient status @@ -180,9 +178,12 @@ def fetch_storage_client_status( storageclient_status(str): storageclient phase """ + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] + cmd = ( - f"oc get storageclient {storageclient_name} -n {namespace} " - "-o=jsonpath='{.items[*].status.phase}'" + f"get storageclient {storageclient_name} -n {namespace} " + "-o=jsonpath='{.status.phase}'" ) storageclient_status = self.ocp_obj.exec_oc_cmd( command=cmd, out_yaml_format=False @@ -300,7 +301,7 @@ def verify_storagerequest_exists( storagerequest_exists (bool): returns true if the storagerequest exists """ - cmd = f"oc get storagerequests -n {namespace} " "-o=jsonpath='{.items[*]}'" + cmd = f"get storagerequests -n {namespace} " "-o=jsonpath='{.items[*]}'" storage_requests = self.ocp_obj.exec_oc_cmd(command=cmd, out_yaml_format=True) log.info(f"The list of storagerequests: {storage_requests}") @@ -315,7 +316,7 @@ def verify_storagerequest_exists( def verify_storageclient_status( self, storageclient_name, - namespace=config.ENV_DATA["cluster_namespace"], + namespace=None, expected_storageclient_status="Connected", ): """ @@ -330,10 +331,12 @@ def verify_storageclient_status( storagerequest_phase == expected_storageclient_status """ + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] # Check storage client is in 'Connected' status storage_client_status = self.fetch_storage_client_status( - storageclient_name, namespace=namespace + storageclient_name=storageclient_name, namespace=namespace ) assert ( storage_client_status == expected_storageclient_status @@ -430,7 +433,7 @@ def create_native_storage_client( onboarding_token=onboarding_token, ) - if self.ocs_version < 4.16: + if self.ocs_version < version.VERSION_4_16: self.create_storageclaim( storageclaim_name="ocs-storagecluster-ceph-rbd", type="blockpool", @@ -451,7 +454,7 @@ def verify_native_storageclient(self): storageclaims, associated storageclasses and storagerequests are created successfully. """ - if self.ocs_version >= 4.16: + if self.ocs_version >= version.VERSION_4_16: namespace = config.ENV_DATA["cluster_namespace"] else: namespace = constants.OPENSHIFT_STORAGE_CLIENT_NAMESPACE @@ -460,12 +463,15 @@ def verify_native_storageclient(self): kind=constants.STORAGECLIENT, namespace=namespace, ) + storageclient = storageclient_obj.get()["items"][0] + storageclient_name = storageclient["metadata"]["name"] + # Verify storageclient is in Connected status - assert self.verify_storageclient_status(namespace=namespace) + self.verify_storageclient_status( + storageclient_name=storageclient_name, namespace=namespace + ) # Validate storageclaims are Ready and associated storageclasses are created - storageclient = storageclient_obj.get()["items"][0] - storageclient_name = storageclient["metadata"]["name"] verify_storageclient_storageclass_claims(storageclient_name) # Validate storagerequests are created successfully diff --git a/ocs_ci/templates/ocs-deployment/local-storage-optional-operators.yaml b/ocs_ci/templates/ocs-deployment/local-storage-optional-operators.yaml index e855a8d6779..3eedad44cc3 100644 --- a/ocs_ci/templates/ocs-deployment/local-storage-optional-operators.yaml +++ b/ocs_ci/templates/ocs-deployment/local-storage-optional-operators.yaml @@ -27,6 +27,6 @@ spec: icon: base64data: "" mediatype: "" - image: quay.io/openshift-qe-optional-operators/ocp4-index:latest + image: quay.io/openshift-qe-optional-operators/aosqe-index:latest publisher: Red Hat sourceType: grpc