From 7434af8525f29d155e180c5596a83acde58d5a16 Mon Sep 17 00:00:00 2001 From: vavuthu Date: Wed, 23 Oct 2024 18:18:44 +0530 Subject: [PATCH] exclude NOOBAA_PSQL_12_IMAGE for image verification after upgrade Signed-off-by: vavuthu --- ocs_ci/ocs/constants.py | 1 + ocs_ci/ocs/ocp.py | 14 +++++++++++++- ocs_ci/ocs/ocs_upgrade.py | 7 ++++++- ocs_ci/ocs/resources/pod.py | 7 +++++-- 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index e045c24d1c3..599b3161ad8 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -1689,6 +1689,7 @@ MIRROR_OPENSHIFT_PASSWORD_FILE = "mirror_openshift_password" NOOBAA_POSTGRES_CONFIGMAP = "noobaa-postgres-config" NOOBAA_POSTGRES_SECRET = "noobaa-pgsql-secret" +NOOBAA_POSTGRES_12_VERSION = 12 ROOK_CEPH_OPERATOR = "rook-ceph-operator" ROOK_CEPH_CSI_CONFIG = "rook-ceph-csi-config" PDBSTATEMAP = "rook-ceph-pdbstatemap" diff --git a/ocs_ci/ocs/ocp.py b/ocs_ci/ocs/ocp.py index 5c32064c948..5197ccff55f 100644 --- a/ocs_ci/ocs/ocp.py +++ b/ocs_ci/ocs/ocp.py @@ -1461,19 +1461,31 @@ def get_images(data, images=None): return images -def verify_images_upgraded(old_images, object_data): +def verify_images_upgraded(old_images, object_data, ignore_psql_12_verification=False): """ Verify that all images in ocp object are upgraded. Args: old_images (set): Set with old images. object_data (dict): OCP object yaml data. + ignore_psql_12_verification (bool): If True, psql 12 image is removed from current_images for verification Raises: NonUpgradedImagesFoundError: In case the images weren't upgraded. """ current_images = get_images(object_data) + # from 4.15, noobaa-operator pod has NOOBAA_PSQL_12_IMAGE along with NOOBAA_DB_IMAGE + if ( + ignore_psql_12_verification + and "noobaa_psql_12" in current_images + and constants.NOOBAA_OPERATOR_DEPLOYMENT + in object_data.get("metadata").get("name") + ): + log.info( + f'deleting noobaa_psql_12 image from current images for {object_data.get("metadata").get("name")}' + ) + del current_images["noobaa_psql_12"] not_upgraded_images = set( [image for image in current_images.values() if image in old_images] ) diff --git a/ocs_ci/ocs/ocs_upgrade.py b/ocs_ci/ocs/ocs_upgrade.py index f2a8c7f47f9..8108c048417 100644 --- a/ocs_ci/ocs/ocs_upgrade.py +++ b/ocs_ci/ocs/ocs_upgrade.py @@ -43,7 +43,7 @@ mcg_only_install_verification, ocs_install_verification, ) -from ocs_ci.ocs.utils import setup_ceph_toolbox +from ocs_ci.ocs.utils import setup_ceph_toolbox, get_expected_nb_db_psql_version from ocs_ci.utility import version from ocs_ci.utility.reporting import update_live_must_gather_image from ocs_ci.utility.rgwutils import get_rgw_count @@ -153,12 +153,17 @@ def verify_image_versions(old_images, upgrade_version, version_before_upgrade): "minCount", constants.MIN_NB_ENDPOINT_COUNT_POST_DEPLOYMENT ) noobaa_pods = default_noobaa_pods + min_endpoints + noobaa_db_psql_version = get_expected_nb_db_psql_version() + ignore_psql_12_verification = True + if int(noobaa_db_psql_version) == constants.NOOBAA_POSTGRES_12_VERSION: + ignore_psql_12_verification = False try: verify_pods_upgraded( old_images, selector=constants.NOOBAA_APP_LABEL, count=noobaa_pods, timeout=1020, + ignore_psql_12_verification=ignore_psql_12_verification, ) except TimeoutException as ex: if upgrade_version >= parse_version("4.7"): diff --git a/ocs_ci/ocs/resources/pod.py b/ocs_ci/ocs/resources/pod.py index e31b2c65af3..a2c863542e6 100644 --- a/ocs_ci/ocs/resources/pod.py +++ b/ocs_ci/ocs/resources/pod.py @@ -2166,7 +2166,9 @@ def _check_nb_pods_status(): sampler.wait_for_func_status(True) -def verify_pods_upgraded(old_images, selector, count=1, timeout=720): +def verify_pods_upgraded( + old_images, selector, count=1, timeout=720, ignore_psql_12_verification=False +): """ Verify that all pods do not have old image. @@ -2175,6 +2177,7 @@ def verify_pods_upgraded(old_images, selector, count=1, timeout=720): selector (str): Selector (e.g. app=ocs-osd) count (int): Number of resources for selector. timeout (int): Timeout in seconds to wait for pods to be upgraded. + ignore_psql_12_verification (bool): If True, psql 12 image is removed from current_images for verification Raises: TimeoutException: If the pods didn't get upgraded till the timeout. @@ -2202,7 +2205,7 @@ def verify_pods_upgraded(old_images, selector, count=1, timeout=720): ) for pod in pods: pod_obj = pod.get() - verify_images_upgraded(old_images, pod_obj) + verify_images_upgraded(old_images, pod_obj, ignore_psql_12_verification) current_pod_images = get_images(pod_obj) for container_name, container_image in current_pod_images.items(): if container_name not in pod_images: