Skip to content

Commit

Permalink
Address few more review comments by Petr
Browse files Browse the repository at this point in the history
Simplify build tag extraction for submariner

Signed-off-by: Shylesh Kumar Mohan <[email protected]>
  • Loading branch information
shylesh committed Oct 26, 2023
1 parent bd7f883 commit e2e87ce
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 49 deletions.
7 changes: 6 additions & 1 deletion ocs_ci/deployment/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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":
Expand Down
5 changes: 2 additions & 3 deletions ocs_ci/deployment/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
27 changes: 10 additions & 17 deletions ocs_ci/ocs/acm/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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():
Expand Down
1 change: 1 addition & 0 deletions ocs_ci/ocs/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 0 additions & 27 deletions ocs_ci/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit e2e87ce

Please sign in to comment.