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 1 commit
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-rhel8:v0.16"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Latest version is 0.17 and it should be subctl-rhel9 for 0.17

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we are still running on CentOS stream 8 , this might cause the compatibility issues to run on RHEL 8 based system as we recently saw with glibc issue.

We are going to move in matter of weeks to CentOS stream9 , but cannot say when exactly.

It can run without an issue, but might not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tried this on centos stream rlease 9 and its working

21 changes: 21 additions & 0 deletions ocs_ci/deployment/acm.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,27 @@ 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):
subctl_ver = config.ENV_DATA["subctl_version"]
cmd = (
f"oc image {constants.SUBCTL_DOWNSTREAM_URL}{subctl_ver} "
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing extract option in the cmd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will need to use:
--filter-by-os
With value
linux/arm64 - Apple M chips
linux/amd64 - regular x86_64

Some example from local testing:

$ oc image extract --filter-by-os linux/arm64 --registry-config ./path-to/pull-secret-ocs-ci registry.redhat.io/rhacm2/subctl-rhel8:v0.14 --confirm --path "/dist/subctl-v0.14*-linux-*.tar.xz":./
$ ls -l
total 43752
-rw-r-----@ 1 pbalogh  staff    11M Nov 16 00:32 subctl-v0.14.7-linux-amd64.tar.xz
-rw-r-----@ 1 pbalogh  staff   9.9M Nov 16 00:31 subctl-v0.14.7-linux-arm64.tar.xz

The previous file was subctl-v0.14.7-linux-amd64.tar.xz was actually downloaded before when I tried without specifying the --filter-by-os linux/arm64

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

f'--path="/dist/{subctl_ver}*-linux-amd64.tar.xz":/tmp --confirm'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should get this amd64 dynamically based on currently running platform. As we can run ocs-ci on Apple Silicone chips like M1 - M2 ... we should consider to support also this arm64 binairies.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now just added the conditional statement for x86_64 processor, I think we need a list of all supported ocs-ci platform names, ofcourse we need to check platforms for which binaries are available.

)
run_cmd(cmd)
decompress = f"tar -C /tmp/ -xf /tmp/{subctl_ver}*--linux-amd64.tar.xz"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The two dashes (--linux ) are there intentionally?

Suggested change
decompress = f"tar -C /tmp/ -xf /tmp/{subctl_ver}*--linux-amd64.tar.xz"
decompress = f"tar -C /tmp/ -xf /tmp/{subctl_ver}*-linux-amd64.tar.xz"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dahorak , ya typo while copy pasting

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

run_cmd(decompress)
target_dir = os.path.expanduser("~/.local/bin/subctl")
install_cmd = (
f"install -m744 /tmp/{subctl_ver}*/{subctl_ver}*-linux-amd64 {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