Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download subctl downstream if not present #9657

Merged
merged 5 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions conf/ocsci/submariner_downstream.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
ENV_DATA:
submariner_source: "downstream"
subctl_version: "subctl-rhel9:v0.17"
38 changes: 38 additions & 0 deletions ocs_ci/deployment/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import requests

import semantic_version
import platform

from ocs_ci.framework import config
from ocs_ci.ocs import constants
from ocs_ci.ocs.exceptions import (
CommandFailed,
DRPrimaryNotFoundException,
UnsupportedPlatformError,
)
from ocs_ci.utility import templating
from ocs_ci.ocs.utils import get_non_acm_cluster_config
Expand Down Expand Up @@ -157,6 +159,42 @@ def download_binary(self):
os.path.expanduser("~/.local/bin/subctl"),
os.path.join(config.RUN["bin_dir"], "subctl"),
)
elif self.source == "downstream":
self.download_downstream_binary

def download_downstream_binary(self):
"""
Download downstream subctl binary

Raises:
UnsupportedPlatformError : If current platform has no supported subctl binary
"""

subctl_ver = config.ENV_DATA["subctl_version"]
processor = platform.processor()
arch = platform.machine()
if arch == "x86_64" and processor == "x86_64":
binary_pltfrm = "amd64"
sidhant-agrawal marked this conversation as resolved.
Show resolved Hide resolved
elif arch == "arm64" and processor == "arm":
binary_pltfrm = "arm64"
else:
raise UnsupportedPlatformError(
"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'
)
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"),
)

def submariner_configure_upstream(self):
"""
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 @@ -2223,6 +2223,7 @@
"&rows_per_page=25&delta=1296000&contains=submariner-operator-bundle-container-v"
)
SUBMARINER_BREW_REPO = "brew.registry.redhat.io/rh-osbs/iib"
SUBCTL_DOWNSTREAM_URL = "registry.redhat.io/rhacm2/"

# Multicluster related

Expand Down
16 changes: 16 additions & 0 deletions tests/functional/disaster-recovery/regional-dr/conftest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import logging
import pytest

from ocs_ci.framework import config
from ocs_ci.ocs import constants
from ocs_ci.deployment import acm
from ocs_ci.utility.utils import run_cmd
from ocs_ci.ocs.exceptions import CommandFailed

log = logging.getLogger(__name__)

Expand All @@ -20,3 +25,14 @@ def pytest_collection_modifyitems(items):
f"Test {item} is removed from the collected items. Test runs only on RDR clusters"
)
items.remove(item)


@pytest.fixture(autouse=True)
def check_subctl_cli():
# Check whether subctl cli is present
shylesh marked this conversation as resolved.
Show resolved Hide resolved
try:
run_cmd("subctl")
except CommandFailed:
log.debug("subctl binary not found, downloading now...")
submariner = acm.Submariner()
submariner.download_binary()
Loading