Skip to content

Commit

Permalink
Verify the owner of CSI deployments and daemonsets (#9865)
Browse files Browse the repository at this point in the history
* Verify the owner of CSI deployments and daemonsets

Signed-off-by: Jilju Joy <[email protected]>
  • Loading branch information
jilju authored Jun 17, 2024
1 parent eb9a669 commit 0b25e07
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@
L2_ADVERTISEMENT = "L2Advertisement"
METALLB_INSTANCE = "MetalLB"
NETWORK_POLICY = "NetworkPolicy"
DAEMONSET = "DaemonSet"
INGRESSCONTROLLER = "ingresscontroller"

# Provisioners
Expand Down
36 changes: 36 additions & 0 deletions ocs_ci/ocs/resources/storage_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -781,6 +781,42 @@ def ocs_install_verification(
), "Seems like MCG root secrets are public, please check"
log.info("Noobaa root secrets are not public")

# Verify the owner of CSI deployments and daemonsets if not provider mode
if not (managed_service or hci_cluster):
deployment_kind = OCP(kind=constants.DEPLOYMENT, namespace=namespace)
daemonset_kind = OCP(kind=constants.DAEMONSET, namespace=namespace)
for provisioner_name in [
"csi-cephfsplugin-provisioner",
"csi-rbdplugin-provisioner",
]:
provisioner_deployment = deployment_kind.get(resource_name=provisioner_name)
owner_references = provisioner_deployment["metadata"].get("ownerReferences")
assert (
len(owner_references) == 1
), f"Found more than 1 or none owner reference for {constants.DEPLOYMENT} {provisioner_name}"
assert (
owner_references[0].get("kind") == constants.DEPLOYMENT
), f"Owner reference of {constants.DEPLOYMENT} {provisioner_name} is not of kind {constants.DEPLOYMENT}"
assert owner_references[0].get("name") == constants.ROOK_CEPH_OPERATOR, (
f"Owner reference of {constants.DEPLOYMENT} {provisioner_name} "
f"is not {constants.ROOK_CEPH_OPERATOR} {constants.DEPLOYMENT}"
)
log.info("Verified the ownerReferences CSI provisioner deployemts")
for plugin_name in ["csi-cephfsplugin", "csi-rbdplugin"]:
plugin_daemonset = daemonset_kind.get(resource_name=plugin_name)
owner_references = plugin_daemonset["metadata"].get("ownerReferences")
assert (
len(owner_references) == 1
), f"Found more than 1 or none owner reference for {constants.DAEMONSET} {plugin_name}"
assert (
owner_references[0].get("kind") == constants.DEPLOYMENT
), f"Owner reference of {constants.DAEMONSET} {plugin_name} is not of kind {constants.DEPLOYMENT}"
assert owner_references[0].get("name") == constants.ROOK_CEPH_OPERATOR, (
f"Owner reference of {constants.DAEMONSET} {plugin_name} "
f"is not {constants.ROOK_CEPH_OPERATOR} {constants.DEPLOYMENT}"
)
log.info("Verified the ownerReferences CSI plugin daemonsets")


def mcg_only_install_verification(ocs_registry_image=None):
"""
Expand Down

0 comments on commit 0b25e07

Please sign in to comment.