Skip to content

Commit

Permalink
handle hosted cluster ocp version in form x.y
Browse files Browse the repository at this point in the history
get the latest z-stream version for ocp version x.y for hosted cluster

Signed-off-by: Daniel Horak <dahorak@redhat.com>
  • Loading branch information
dahorak committed Nov 12, 2024
1 parent 3a04c37 commit 230e6a9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion ocs_ci/deployment/hosted_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,10 @@ def deploy_ocp(
deploy_acm_hub, deploy_cnv, deploy_metallb, download_hcp_binary
)

ocp_version = config.ENV_DATA["clusters"].get(self.name).get("ocp_version")
ocp_version = str(config.ENV_DATA["clusters"][self.name].get("ocp_version"))
if ocp_version and len(ocp_version.split(".")) == 2:
# if ocp_version is provided in form x.y, we need to get the full form x.y.z
ocp_version = get_latest_release_version(ocp_version)
cpu_cores_per_hosted_cluster = (
config.ENV_DATA["clusters"]
.get(self.name)
Expand Down
9 changes: 7 additions & 2 deletions ocs_ci/utility/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5070,16 +5070,21 @@ def get_architecture_host():
return os.uname().machine


def get_latest_release_version():
def get_latest_release_version(version="latest"):
"""
Fetch the latest supported release version of OpenShift from its official mirror site.
Args:
version (str): OCP version in form X.Y to get the latest z-stream release version or "latest" (default)
Returns:
str: The latest release version. Example: As of 22 May 2024 the function returns string "4.15.14"
"""
if "latest" not in version:
version = f"latest-{version}"
cmd = (
"curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/latest/release.txt | "
f"curl -sL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/{version}/release.txt | "
"awk '/^Name:/ {print $2}'"
)
try:
Expand Down

0 comments on commit 230e6a9

Please sign in to comment.