From cbd3eb40e66acb24118a95cda52abd5c5ade66e9 Mon Sep 17 00:00:00 2001 From: Shylesh Kumar Mohan Date: Wed, 15 May 2024 06:04:53 +0100 Subject: [PATCH] Fix subctl download issue Signed-off-by: Shylesh Kumar Mohan --- ocs_ci/deployment/acm.py | 26 +++++++++++-------- .../disaster-recovery/regional-dr/conftest.py | 4 ++- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ocs_ci/deployment/acm.py b/ocs_ci/deployment/acm.py index 06a89f8e99ca..ecd77f3afb89 100644 --- a/ocs_ci/deployment/acm.py +++ b/ocs_ci/deployment/acm.py @@ -7,6 +7,7 @@ import tempfile import shutil import requests +import time import semantic_version import platform @@ -160,7 +161,7 @@ def download_binary(self): os.path.join(config.RUN["bin_dir"], "subctl"), ) elif self.source == "downstream": - self.download_downstream_binary + self.download_downstream_binary() def download_downstream_binary(self): """ @@ -171,6 +172,8 @@ def download_downstream_binary(self): """ subctl_ver = config.ENV_DATA["subctl_version"] + version_str = subctl_ver.split(":")[1] + pull_secret_path = os.path.join(constants.DATA_DIR, "pull-secret") processor = platform.processor() arch = platform.machine() if arch == "x86_64" and processor == "x86_64": @@ -182,19 +185,20 @@ def download_downstream_binary(self): "Not a supported architecture for subctl binary" ) cmd = ( - f"oc image extract {constants.SUBCTL_DOWNSTREAM_URL}{subctl_ver} " - f'--path="/dist/{subctl_ver}*-linux-{binary_pltfrm}.tar.xz":/tmp --confirm' + f"oc image extract --registry-config {pull_secret_path} {constants.SUBCTL_DOWNSTREAM_URL}{subctl_ver} " + f'--path="/dist/subctl-{version_str}*-linux-{binary_pltfrm}.tar.xz":/tmp --confirm' ) run_cmd(cmd) - decompress = f"tar -C /tmp/ -xf /tmp/{subctl_ver}*-linux-{binary_pltfrm}.tar.xz" - run_cmd(decompress) - target_dir = os.path.expanduser("~/.local/bin/subctl") - install_cmd = f"install -m744 /tmp/{subctl_ver}*/{subctl_ver}*-linux-{binary_pltfrm} {target_dir} " - run_cmd(install_cmd) - shutil.copyfile( - os.path.expanduser(f"{target_dir}"), - os.path.join(config.RUN["bin_dir"], "subctl"), + # Wait till image extract happens and subctl dir appears + time.sleep(30) + decompress = ( + f"tar -C /tmp/ -xf /tmp/subctl-{version_str}*-linux-{binary_pltfrm}.tar.xz" ) + run_cmd(decompress) + target_dir = os.path.expanduser("./bin") + install_cmd = f"install -m744 /tmp/subctl-{version_str}*/subctl-{version_str}*-linux-{binary_pltfrm} {target_dir} " + run_cmd(install_cmd, shell=True) + run_cmd(f"mv {target_dir}/subctl-* {target_dir}/subctl", shell=True) def submariner_configure_upstream(self): """ diff --git a/tests/functional/disaster-recovery/regional-dr/conftest.py b/tests/functional/disaster-recovery/regional-dr/conftest.py index 9d2546702722..51a8c494cc8e 100644 --- a/tests/functional/disaster-recovery/regional-dr/conftest.py +++ b/tests/functional/disaster-recovery/regional-dr/conftest.py @@ -30,9 +30,11 @@ def pytest_collection_modifyitems(items): @pytest.fixture(autouse=True) def check_subctl_cli(): # Check whether subctl cli is present + if config.MULTICLUSER.get("multicluster_mode") != constants.RDR_MODE: + return try: run_cmd("subctl") - except CommandFailed: + except (CommandFailed, FileNotFoundError): log.debug("subctl binary not found, downloading now...") submariner = acm.Submariner() submariner.download_binary()