Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions ocs_ci/deployment/mce.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import logging
import tempfile
import json

from ocs_ci.deployment.qe_app_registry import QeAppRegistry
from ocs_ci.ocs import ocp
Expand All @@ -16,6 +17,7 @@
run_cmd,
exec_cmd,
wait_custom_resource_defenition_available,
TimeoutSampler,
)
from ocs_ci.ocs.resources.catalog_source import CatalogSource
from ocs_ci.ocs.resources.deployment import Deployment
Expand Down Expand Up @@ -188,24 +190,42 @@ def check_supported_versions(self):

if not configmaps_obj.check_resource_existence(
should_exist=True,
timeout=600,
timeout=300,
resource_name=constants.SUPPORTED_VERSIONS_CONFIGMAP,
):
raise UnavailableResourceException(
f"Configmap {constants.SUPPORTED_VERSIONS_CONFIGMAP} does not exist "
f"in {constants.HYPERSHIFT_NAMESPACE} namespace"
)

ocp_version = get_running_ocp_version()
supported_versions = self.get_supported_versions()

if not get_running_ocp_version() in supported_versions:
self.create_image_override()

sampler = TimeoutSampler(
timeout=600,
sleep=10,
func=lambda: ocp_version in self.get_supported_versions(),
)
if sampler.wait_for_func_value(True):
logger.info(f"Version {ocp_version} found in supported-versions configmap")

def get_supported_versions(self):
"""
Get supported versions from the supported-versions configmap.

Returns:
str: Supported versions string or empty string if command fails.
"""
cmd = f"oc get cm -n {constants.HYPERSHIFT_NAMESPACE} supported-versions "
cmd += "-o jsonpath='{.data.supported-versions}'"
cmd_res = exec_cmd(cmd, shell=True)
supported_versions = ""
if cmd_res.returncode == 0:
supported_versions = cmd_res.stdout.decode("utf-8")
logger.info(f"Supported versions: {supported_versions}")

if not get_running_ocp_version() in supported_versions:
self.create_image_override()
versions_data = json.loads(cmd_res.stdout.decode("utf-8"))
return versions_data.get("versions", [])
return []

def create_image_override(self):
"""
Expand All @@ -224,7 +244,6 @@ def create_image_override(self):
self.multicluster_engine.annotate(
annotation=f"imageOverridesCM={self.hypershift_override_image_cm}"
)
self.multicluster_engine.wait_until_running()

def deploy_mce(self):
"""
Expand Down