diff --git a/ocs_ci/deployment/provider_client/storage_client_deployment.py b/ocs_ci/deployment/provider_client/storage_client_deployment.py index 1165e6c59684..8bfefd1fe24a 100644 --- a/ocs_ci/deployment/provider_client/storage_client_deployment.py +++ b/ocs_ci/deployment/provider_client/storage_client_deployment.py @@ -10,7 +10,10 @@ from ocs_ci.framework import config from ocs_ci.ocs import constants, ocp, defaults -from ocs_ci.ocs.rados_utils import RadosHelper +from ocs_ci.ocs.rados_utils import ( + verify_cephblockpool_status, + check_phase_of_rados_namespace, +) from ocs_ci.deployment.helpers.lso_helpers import setup_local_storage from ocs_ci.ocs.node import label_nodes, get_all_nodes, get_node_objs from ocs_ci.ocs.ui.validation_ui import ValidationUI @@ -101,7 +104,6 @@ def setup(self): ] self.ocs_client_operator = defaults.OCS_CLIENT_OPERATOR_NAME self.deployment = Deployment() - self.rados_utils = RadosHelper() def provider_and_native_client_installation( self, @@ -255,9 +257,6 @@ def provider_and_native_client_installation( self.deployment.wait_for_csv( self.ocs_client_operator, constants.OPENSHIFT_STORAGE_NAMESPACE ) - log.info( - f"Sleeping for 30 seconds after {self.ocs_client_operator} created" - ) # Validate storageclaims are Ready and associated storageclasses are created verify_storageclient() @@ -267,12 +266,12 @@ def provider_and_native_client_installation( constants.DEFAULT_BLOCKPOOL ), f"{constants.DEFAULT_BLOCKPOOL} is not created" assert ( - self.rados_utils.verify_cephblockpool_status() + verify_cephblockpool_status() ), "the cephblockpool is not in Ready phase" # Validate radosnamespace created and in 'Ready' status assert ( - self.rados_utils.check_phase_of_rados_namespace() + check_phase_of_rados_namespace() ), "The radosnamespace is not in Ready phase" # Validate storageclassrequests created @@ -381,14 +380,6 @@ def odf_subscription_on_provider(self): run_cmd(f"oc create -f {constants.OLM_YAML}") self.deployment.subscribe_ocs() - # Wait until odf is installed - odf_operator = defaults.ODF_OPERATOR_NAME - self.deployment.wait_for_subscription( - odf_operator, constants.OPENSHIFT_STORAGE_NAMESPACE - ) - self.deployment.wait_for_csv(odf_operator, config.ENV_DATA["cluster_namespace"]) - log.info(f"Sleeping for 30 seconds after {odf_operator} created") - time.sleep(30) ocs_version = version.get_semantic_ocs_version_from_config() log.info(f"Installed odf version: {ocs_version}") self.validation_ui_obj.refresh_web_console() diff --git a/ocs_ci/ocs/rados_utils.py b/ocs_ci/ocs/rados_utils.py index 7dcd75b38d3c..cf3c8f8510c1 100644 --- a/ocs_ci/ocs/rados_utils.py +++ b/ocs_ci/ocs/rados_utils.py @@ -277,80 +277,82 @@ def get_mgr_proxy_container(self, node, docker_image, proxy_container="mgr_proxy return mgr_object - def verify_cephblockpool_status( - self, - pool_name=constants.DEFAULT_BLOCKPOOL, - namespace=None, - required_phase=constants.STATUS_READY, - ): - """ - Verify the phase of cephblockpool - Args: - pool_name (str): The name of the Ceph block pool - namespace(str): cluster namespace - required_phase(str): required phase of the cephblockpool +def verify_cephblockpool_status( + pool_name=constants.DEFAULT_BLOCKPOOL, + namespace=None, + required_phase=constants.STATUS_READY, +): + """ + Verify the phase of cephblockpool - Returns: - status: True if the Ceph block pool is in Ready status, False otherwise - """ - if not namespace: - namespace = config.ENV_DATA["cluster_namespace"] - cmd = ( - f"oc get {constants.CEPHBLOCKPOOL} {pool_name} -n {namespace} " - "-o=jsonpath='{.status.phase}'" - ) + Args: + pool_name (str): The name of the Ceph block pool + namespace(str): cluster namespace + required_phase(str): required phase of the cephblockpool - phase = retry((CommandFailed), tries=20, delay=10,)( - run_cmd - )(cmd=cmd) + Returns: + status: True if the Ceph block pool is in Ready status, False otherwise + """ + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] + cmd = ( + f"oc get {constants.CEPHBLOCKPOOL} {pool_name} -n {namespace} " + "-o=jsonpath='{.status.phase}'" + ) - logger.info(f"{pool_name} is in {phase} phase") - logger.info(f"Required phase is {required_phase}") - return phase == required_phase + phase = retry((CommandFailed), tries=20, delay=10,)( + run_cmd + )(cmd=cmd) - def fetch_rados_namespaces(self, namespace=None): - """ - Verify if rados namespace exists + logger.info(f"{pool_name} is in {phase} phase") + logger.info(f"Required phase is {required_phase}") + return phase == required_phase - Args: - namespace(str): cluster namespace - Returns: - bool: True if the radosnamespace exists, False otherwise - """ - logger.info("Fetch radosnamespaces exist") - if not namespace: - namespace = config.ENV_DATA["cluster_namespace"] - rados_ns_obj = ocp.OCP(kind=constants.CEPHBLOCKPOOLRADOSNS, namespace=namespace) - result = rados_ns_obj.get() - sample = result["items"] - rados_ns_list = [item.get("metadata").get("name") for item in sample] - return rados_ns_list - - def check_phase_of_rados_namespace( - self, namespace=None, required_phase=constants.STATUS_READY - ): - """ - Verify if rados namespace exists +def fetch_rados_namespaces(namespace=None): + """ + Verify if rados namespace exists - Args: - namespace(str): cluster namespace - required_phase(str): required phase of the rados namespace + Args: + namespace(str): cluster namespace - Returns: - bool: True if the radosnamespace exists, False otherwise - """ - logger.info("Verifying if radosnamespace is in desired phase") - if not namespace: - namespace = config.ENV_DATA["cluster_namespace"] - for rados_namespace in self.fetch_rados_namespaces(namespace=namespace): - check_radosns_phase_cmd = ( - f"oc get {constants.CEPHBLOCKPOOLRADOSNS} {rados_namespace} -n {namespace} " - "-o=jsonpath='{.status.phase}'" - ) - phase = run_cmd(cmd=check_radosns_phase_cmd) - return phase == required_phase + Returns: + bool: True if the radosnamespace exists, False otherwise + """ + logger.info("Fetch radosnamespaces exist") + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] + rados_ns_obj = ocp.OCP(kind=constants.CEPHBLOCKPOOLRADOSNS, namespace=namespace) + result = rados_ns_obj.get() + sample = result["items"] + rados_ns_list = [item.get("metadata").get("name") for item in sample] + return rados_ns_list + + +def check_phase_of_rados_namespace( + namespace=None, required_phase=constants.STATUS_READY +): + """ + Verify if rados namespace exists + + Args: + namespace(str): cluster namespace + required_phase(str): required phase of the rados namespace + + Returns: + bool: True if the radosnamespace exists, False otherwise + """ + logger.info("Verifying if radosnamespace is in desired phase") + if not namespace: + namespace = config.ENV_DATA["cluster_namespace"] + for rados_namespace in fetch_rados_namespaces(namespace=namespace): + check_radosns_phase_cmd = ( + f"oc get {constants.CEPHBLOCKPOOLRADOSNS} {rados_namespace} -n {namespace} " + "-o=jsonpath='{.status.phase}'" + ) + phase = run_cmd(cmd=check_radosns_phase_cmd) + return phase == required_phase def corrupt_pg(osd_deployment, pool_name, pool_object):