Skip to content

Commit

Permalink
updated with storageclass claim verification
Browse files Browse the repository at this point in the history
Signed-off-by: Amrita Mahapatra <[email protected]>
  • Loading branch information
amr1ta committed Apr 16, 2024
1 parent 5cad2ab commit 76ed40b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 19 deletions.
17 changes: 8 additions & 9 deletions ocs_ci/deployment/provider_client/storage_client_deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@
check_phase_of_rados_namespace,
)
from ocs_ci.ocs.exceptions import CommandFailed
from ocs_ci.helpers.managed_services import (
verify_storageclient,
verify_storageclient_storageclass_claims,
)


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -224,7 +228,9 @@ def provider_and_native_client_installation(
log.info(
f"Sleeping for 30 seconds after {self.ocs_client_operator} created"
)
# Validate storageclaims created

# Validate storageclaims are Ready and associated storageclasses are created
verify_storageclient()

# Validate cephblockpool created
assert verify_block_pool_exists(
Expand Down Expand Up @@ -574,11 +580,4 @@ def create_storage_client(
f"apply -f {constants.STORAGE_CLASS_CLAIM_YAML}"
)
time.sleep(30)
storage_class_classes = get_all_storageclass_names()
for storage_class in self.storage_class_claims:
assert (
storage_class in storage_class_classes
), "Storage classes ae not created as expected"

else:
log.error("storageclassclaims are not created")
verify_storageclient_storageclass_claims(resource_name)
36 changes: 26 additions & 10 deletions ocs_ci/helpers/managed_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ocs_ci.utility.utils import convert_device_size, TimeoutSampler
from ocs_ci.utility.aws import AWS
import ocs_ci.ocs.cluster
from ocs_ci.utility import version

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -253,6 +254,7 @@ def verify_storageclient(
verify_sc (bool): True to verify the storageclassclaims and storageclasses associated with the storageclient.
"""
ocs_version = version.get_semantic_ocs_version_from_config()
storageclient_obj = OCP(
kind=constants.STORAGECLIENT,
namespace=namespace or config.ENV_DATA["cluster_namespace"],
Expand All @@ -263,13 +265,20 @@ def verify_storageclient(
else storageclient_obj.get()["items"][0]
)
storageclient_name = storageclient["metadata"]["name"]
provider_name = provider_name or config.ENV_DATA.get("provider_name", "")
endpoint_actual = get_storage_provider_endpoint(provider_name)
assert storageclient["spec"]["storageProviderEndpoint"] == endpoint_actual, (
f"The value of storageProviderEndpoint is not correct in the storageclient {storageclient['metadata']['name']}."
f" Value in storageclient is {storageclient['spec']['storageProviderEndpoint']}. "
f"Value in the provider cluster {provider_name} is {endpoint_actual}"
)

if ocs_version >= version.VERSION_4_16:
assert (
storageclient["spec"]["storageProviderEndpoint"]
== "ocs-provider-server:50051"
)
else:
provider_name = provider_name or config.ENV_DATA.get("provider_name", "")
endpoint_actual = get_storage_provider_endpoint(provider_name)
assert storageclient["spec"]["storageProviderEndpoint"] == endpoint_actual, (
f"The value of storageProviderEndpoint is not correct in storageclient {storageclient['metadata']['name']}."
f" Value in storageclient is {storageclient['spec']['storageProviderEndpoint']}. "
f"Value in the provider cluster {provider_name} is {endpoint_actual}"
)
log.info(
f"Verified the storageProviderEndpoint value in the storageclient {storageclient_name}"
)
Expand Down Expand Up @@ -313,9 +322,16 @@ def get_all_storageclassclaims():
List: OCS objects of kind Storageclassclaim
"""
sc_claim_obj = OCP(
kind=constants.STORAGECLASSCLAIM, 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"]
)
else:
sc_claim_obj = OCP(
kind=constants.STORAGECLASSCLAIM,
namespace=config.ENV_DATA["cluster_namespace"],
)
sc_claims_data = sc_claim_obj.get()["items"]
return [OCS(**claim_data) for claim_data in sc_claims_data]

Expand Down
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
LVMCLUSTER = "odf-lvmcluster"
LVMSCLUSTER = "lvmscluster"
STORAGECLASSCLAIM = "StorageClassClaim"
STORAGECLAIM = "StorageClaim"
STORAGECONSUMER = "StorageConsumer"
MACHINEHEALTHCHECK = "machinehealthcheck"
STORAGECLIENT = "StorageClient"
Expand Down

0 comments on commit 76ed40b

Please sign in to comment.