Skip to content

Commit

Permalink
Merge pull request #10723 from vavuthu/fix_upgrade_issue_image_for_no…
Browse files Browse the repository at this point in the history
…obaa_psql_12

exclude NOOBAA_PSQL_12_IMAGE for image verification after upgrade
  • Loading branch information
vavuthu authored Nov 22, 2024
2 parents 2c642a3 + 7434af8 commit ccd8359
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 13 additions & 1 deletion ocs_ci/ocs/ocp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
)
Expand Down
7 changes: 6 additions & 1 deletion ocs_ci/ocs/ocs_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"):
Expand Down
7 changes: 5 additions & 2 deletions ocs_ci/ocs/resources/pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit ccd8359

Please sign in to comment.