Skip to content

Commit

Permalink
Fix subctl download issue
Browse files Browse the repository at this point in the history
Signed-off-by: Shylesh Kumar Mohan <[email protected]>
  • Loading branch information
shylesh committed May 15, 2024
1 parent e06cbba commit cbd3eb4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
26 changes: 15 additions & 11 deletions ocs_ci/deployment/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import tempfile
import shutil
import requests
import time

import semantic_version
import platform
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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":
Expand All @@ -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):
"""
Expand Down
4 changes: 3 additions & 1 deletion tests/functional/disaster-recovery/regional-dr/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit cbd3eb4

Please sign in to comment.