Skip to content

Commit

Permalink
add support for latest rosa version (#1242)
Browse files Browse the repository at this point in the history
add the support to create a new ROSA cluster with
OPENSHIFT_VERSION=x.y-latest
in this case, it will retrieve the latest ROSA version and use it.
 
related to jira ticket: RHOAIENG-2683
  • Loading branch information
kobihk authored Mar 3, 2024
2 parents 9e364e0 + dec05d5 commit baf36fb
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ods_ci/utils/scripts/rosa/rosa.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import argparse
import os
import re
import sys

dir_path = os.path.dirname(os.path.abspath(__file__))
sys.path.append(dir_path + "/../")
from awsOps import aws_configure
from logger import log
from rosaOps import create_account_roles, rosa_create_cluster, rosa_whoami, wait_for_osd_cluster_to_be_ready
from util import execute_command


class RosaClusterManager:
Expand All @@ -21,6 +23,21 @@ def __init__(self, args={}):
self.rosa_version = args.get("rosa_version")
self.channel_name = args.get("channel_name")

def set_rosa_version(self):
version_match = re.match(r"(\d+\.\d+)\-latest", self.rosa_version)
if version_match is None:
log.info(f"Using the rosa version given by user: {self.rosa_version}")
return
log.info(f"User provided {self.rosa_version}, trying to determine the appropriate latest version for ROSA")
version = version_match.group(1)
latest_version_cmd = (
f"rosa list versions --channel-group {self.channel_name} | "
f"awk '{{print $1}}' | grep -w '^{re.escape(version)}*' | head -n1"
)
latest_version = execute_command(latest_version_cmd)
self.rosa_version = latest_version.strip()
log.info(f"Using the latest rosa version: {self.rosa_version}")

def create_rosa_cluster(self):
log.info(
"Creating ROSA cluster with the following details:\n"
Expand All @@ -33,6 +50,7 @@ def create_rosa_cluster(self):
)
aws_configure(self.aws_access_key_id, self.aws_secret_access_key, self.aws_region, self.aws_profile)
rosa_whoami()
self.set_rosa_version()
create_account_roles()
rosa_create_cluster(
self.cluster_name,
Expand Down Expand Up @@ -127,7 +145,7 @@ def main():
required=True,
action="store",
dest="channel_name",
help="Channel Group Stable/Candidate",
help="Channel Group stable/candidate",
)
rosa_cluster_manager = RosaClusterManager()

Expand Down

0 comments on commit baf36fb

Please sign in to comment.