Skip to content

Commit

Permalink
addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Amrita Mahapatra <[email protected]>
  • Loading branch information
amr1ta committed May 30, 2024
1 parent 532da3c commit 6157575
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 80 deletions.
21 changes: 6 additions & 15 deletions ocs_ci/deployment/provider_client/storage_client_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand Down
132 changes: 67 additions & 65 deletions ocs_ci/ocs/rados_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 6157575

Please sign in to comment.