From e2e87ce6374c3b7f0327c3dd0f3ec3d6c21b95f0 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Wed, 25 Oct 2023 23:15:19 +0100 Subject: [PATCH] Address few more review comments by Petr Simplify build tag extraction for submariner Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/deployment/acm.py | 7 ++++- ocs_ci/deployment/deployment.py | 5 ++-- ocs_ci/ocs/acm/acm.py | 27 +++++++------------ ocs_ci/ocs/constants.py | 1 + ...bmariner_downstream_unreleased_catsrc.yaml | 2 +- ocs_ci/utility/utils.py | 27 ------------------- 6 files changed, 20 insertions(+), 49 deletions(-) diff --git a/ocs_ci/deployment/acm.py b/ocs_ci/deployment/acm.py index b02b49aa0b7..04b46c78d8f 100644 --- a/ocs_ci/deployment/acm.py +++ b/ocs_ci/deployment/acm.py @@ -18,7 +18,11 @@ ) from ocs_ci.utility import templating from ocs_ci.ocs.utils import get_non_acm_cluster_config -from ocs_ci.utility.utils import run_cmd, run_cmd_interactive +from ocs_ci.utility.utils import ( + run_cmd, + run_cmd_interactive, + wait_for_machineconfigpool_status, +) from ocs_ci.ocs.node import get_typed_worker_nodes, label_nodes logger = logging.getLogger(__name__) @@ -117,6 +121,7 @@ def create_acm_brew_icsp(self): ) templating.dump_data_to_temp_yaml(icsp_data, icsp_data_yaml.name) run_cmd(f"oc create -f {icsp_data_yaml.name}", timeout=300) + wait_for_machineconfigpool_status(node_type="all") def download_binary(self): if self.source == "upstream": diff --git a/ocs_ci/deployment/deployment.py b/ocs_ci/deployment/deployment.py index 39a138787a9..57d72b48a39 100644 --- a/ocs_ci/deployment/deployment.py +++ b/ocs_ci/deployment/deployment.py @@ -376,10 +376,9 @@ def do_deploy_ocs(self): } } } - storage_cluster.data.get("spec").merge_dict( - multicluster_service + merge_dict( + storage_cluster.data.get("spec"), multicluster_service ) - # todo: oc apply updated resource storage_cluster_yaml = tempfile.NamedTemporaryFile( mode="w+", prefix="storageclusterupdate", delete=False ) diff --git a/ocs_ci/ocs/acm/acm.py b/ocs_ci/ocs/acm/acm.py index 69555d1e3bd..0fb71fe5cbb 100644 --- a/ocs_ci/ocs/acm/acm.py +++ b/ocs_ci/ocs/acm/acm.py @@ -2,6 +2,7 @@ import time import os import tempfile +import requests from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.support import expected_conditions as ec @@ -23,9 +24,9 @@ from ocs_ci.ocs.utils import get_non_acm_cluster_config, get_primary_cluster_config from ocs_ci.utility.utils import ( TimeoutSampler, + get_ocp_version, get_running_acm_version, string_chunkify, - chained_subprocess_pipes, run_cmd, ) from ocs_ci.ocs.ui.acm_ui import AcmPageNavigator @@ -167,28 +168,20 @@ def install_submariner_ui(self, globalnet=True): config.ENV_DATA["submariner_version"], ] ) - curl_cmd = f"curl --retry 3 --retry-delay 5 -Ls {submariner_full_url}" - jq_cmd1 = ( - 'jq -r \'[.raw_messages[].msg | select(.pipeline.status=="complete") |' - "{{nvr: .artifact.nvr, index_image: .pipeline.index_image}}] | .[0]'" - ) - jq_cmd2 = "jq -r '.index_image.\"v4.14\"'" - cut_cmd1 = "cut -d'/' -f3-" - cut_cmd2 = "cut -d':' -f2-" - cmd_exec = chained_subprocess_pipes( - [curl_cmd, jq_cmd1, jq_cmd2, cut_cmd1, cut_cmd2] + resp = requests.get(submariner_full_url, verify=False) + raw_msg = resp.json()["raw_messages"] + version_tag = raw_msg[0]["msg"]["pipeline"]["index_image"][ + f"v{get_ocp_version()}" + ].split(":")[1] + submariner_downstream_unreleased["spec"]["image"] = ":".join( + [constants.SUBMARINER_BREW_REPO, version_tag] ) - version_tag = cmd_exec.communicate()[0].decode() - - image_url = submariner_downstream_unreleased["spec"]["image"] - image_url = image_url.replace("PLACE_HOLDER", version_tag) - submariner_downstream_unreleased["spec"]["image"] = image_url submariner_data_yaml = tempfile.NamedTemporaryFile( mode="w+", prefix="submariner_downstream_unreleased", delete=False ) templating.dump_data_to_temp_yaml( - submariner_downstream_unreleased, submariner_data_yaml + submariner_downstream_unreleased, submariner_data_yaml.name ) old_ctx = config.cur_index for cluster in get_non_acm_cluster_config(): diff --git a/ocs_ci/ocs/constants.py b/ocs_ci/ocs/constants.py index 22c1e05cac5..f4c6313e7dd 100644 --- a/ocs_ci/ocs/constants.py +++ b/ocs_ci/ocs/constants.py @@ -2079,6 +2079,7 @@ "VirtualTopic.eng.ci.redhat-container-image.pipeline.complete" "&rows_per_page=25&delta=1296000&contains=submariner-operator-bundle-container-v" ) +SUBMARINER_BREW_REPO = "brew.registry.redhat.io/rh-osbs/iib" # Multicluster related diff --git a/ocs_ci/templates/ocs-deployment/multicluster/submariner_downstream_unreleased_catsrc.yaml b/ocs_ci/templates/ocs-deployment/multicluster/submariner_downstream_unreleased_catsrc.yaml index bab28efe1df..b931afe2ce8 100644 --- a/ocs_ci/templates/ocs-deployment/multicluster/submariner_downstream_unreleased_catsrc.yaml +++ b/ocs_ci/templates/ocs-deployment/multicluster/submariner_downstream_unreleased_catsrc.yaml @@ -7,7 +7,7 @@ spec: icon: base64data: "" mediatype: "" - image: brew.registry.redhat.io/rh-osbs/iib:PLACE_HOLDER + image: PLACE_HOLDER publisher: Red Hat sourceType: grpc priority: 100 diff --git a/ocs_ci/utility/utils.py b/ocs_ci/utility/utils.py index 94cd8b3de5b..a85aead0163 100644 --- a/ocs_ci/utility/utils.py +++ b/ocs_ci/utility/utils.py @@ -4553,30 +4553,3 @@ def is_cluster_y_version_upgraded(): ) > version_module.get_semantic_version(prev_version_num, only_major_minor=True): is_upgraded = True return is_upgraded - - -def chained_subprocess_pipes(cmd_list): - """ - We can use this function wherever we have chain of commands which - need to be piped. Direct shell piping has some parsing issues hence implementing - this using subprocess output redirections which mimics shell pipes. - Commands will be run as per the command ordering inside the list and output of - each command will be fed as input to the next command in the list - - - Args: - cmd_list (list): list of commands to be run whose output need to be piped - - Returns: - Popen object of the last command executed - - """ - pipe_buf = None - for cmd in cmd_list: - if not pipe_buf: - pipe_buf = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE) - else: - pipe_buf = subprocess.Popen( - shlex.split(cmd), stdin=pipe_buf.stdout, stdout=subprocess.PIPE - ) - return pipe_buf