diff --git a/scripts/devenv-builder/configure-vm.sh b/scripts/devenv-builder/configure-vm.sh index 258304dff2..e41a23b6b3 100755 --- a/scripts/devenv-builder/configure-vm.sh +++ b/scripts/devenv-builder/configure-vm.sh @@ -193,29 +193,32 @@ function configure_rhel_subscription() { function configure_rhel_repositories() { sudo subscription-manager config --rhsm.manage_repos=1 + # Extract major version from Makefile.version + local -r ocp_major="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)" + RHOCP=$("${RHOCP_REPO}") - if [[ "${RHOCP}" =~ ^[0-9]{2} ]]; then - sudo subscription-manager repos --enable "rhocp-4.${RHOCP}-for-rhel-9-$(uname -m)-rpms" + if [[ "${RHOCP}" =~ ^[0-9]{1,2}$ ]]; then + sudo subscription-manager repos --enable "rhocp-${ocp_major}.${RHOCP}-for-rhel-9-$(uname -m)-rpms" elif [[ "${RHOCP}" =~ ^http ]]; then url=$(echo "${RHOCP}" | cut -d, -f1) ver=$(echo "${RHOCP}" | cut -d, -f2) - OCP_REPO_NAME="rhocp-4.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms" + OCP_REPO_NAME="rhocp-${ocp_major}.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms" sudo tee "/etc/yum.repos.d/${OCP_REPO_NAME}.repo" >/dev/null <&/dev/null; then exit 1 fi +# Get version of currently checked out branch. +# It's based on values stored in Makefile.version.$ARCH.var. +make_version="${REPOROOT}/Makefile.version.$(uname -m).var" +if [ ! -f "${make_version}" ] ; then + # Attempt to locate the Makefile version file next to the current script. + # This is necessary when bootstrapping the development environment for the first time. + make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1) + if [ ! -f "${make_version}" ] ; then + >&2 echo "Cannot find the Makefile.version.$(uname -m).var file" + exit 1 + fi +fi +current_major=$(grep '^OCP_VERSION' "${make_version}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1) + if [[ "$#" -eq 1 ]]; then current_minor="${1}" stop="${current_minor}" else - # Get minor version of currently checked out branch. - # It's based on values stored in Makefile.version.$ARCH.var. - make_version="${REPOROOT}/Makefile.version.$(uname -m).var" - if [ ! -f "${make_version}" ] ; then - # Attempt to locate the Makefile version file next to the current script. - # This is necessary when bootstrapping the development environment for the first time. - make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1) - if [ ! -f "${make_version}" ] ; then - >&2 echo "Cannot find the Makefile.version.$(uname -m).var file" - exit 1 - fi - fi - current_minor=$(cut -d'.' -f2 "${make_version}") + current_minor=$(grep '^OCP_VERSION' "${make_version}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f2) stop=$(( current_minor - 3 )) fi -# Go through minor versions, starting from current_mirror counting down +# Go through minor versions, starting from current_minor counting down # to get latest available rhocp repository. -# For example, at the time of writing this comment, current_minor is 16, -# and following code will try to access rhocp-4.15 (which is not released yet) -# and then rhocp-4.14 (which will be returned from the script because it's usable). +# For example, if current version is 4.16, the code will try to access +# rhocp-4.15 (which may not be released yet) and then rhocp-4.14 (which +# will be returned if it's usable). Works similarly for version 5.x. for ver in $(seq "${current_minor}" -1 "${stop}"); do - repository="rhocp-4.${ver}-for-rhel-9-$(uname -m)-rpms" + repository="rhocp-${current_major}.${ver}-for-rhel-9-$(uname -m)-rpms" if sudo dnf repository-packages --showduplicates "${repository}" info cri-o 1>&2; then echo "${ver}" exit 0 fi - rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/4.${ver}-el9-beta/" + rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v${current_major}/$(uname -m)/dependencies/rpms/${current_major}.${ver}-el9-beta/" if sudo dnf repository-packages --showduplicates --disablerepo '*' --repofrompath "this,${rhocp_beta_url}" this info cri-o 1>&2; then echo "${rhocp_beta_url},${ver}" exit 0 diff --git a/scripts/release-notes/gen_gh_releases_from_mirror.py b/scripts/release-notes/gen_gh_releases_from_mirror.py index 60a3a4666d..965717ce9e 100755 --- a/scripts/release-notes/gen_gh_releases_from_mirror.py +++ b/scripts/release-notes/gen_gh_releases_from_mirror.py @@ -60,8 +60,10 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s') -URL_BASE = "https://mirror.openshift.com/pub/openshift-v4/aarch64/microshift" -URL_BASE_X86 = "https://mirror.openshift.com/pub/openshift-v4/x86_64/microshift" + +def get_mirror_url_base(major_version, arch): + """Get the mirror URL base for the given major version and architecture.""" + return f"https://mirror.openshift.com/pub/openshift-v{major_version}/{arch}/microshift" # An EC RPM filename looks like # microshift-4.13.0~ec.4-202303070857.p0.gcf0bce2.assembly.ec.4.el9.aarch64.rpm @@ -167,13 +169,17 @@ def main(): if args.versions_to_scan: versions_to_scan = args.versions_to_scan + # Get URL bases for the current major version + url_base_aarch64 = get_mirror_url_base(major, 'aarch64') + url_base_x86 = get_mirror_url_base(major, 'x86_64') + new_releases = [] if args.ec: - new_releases.extend(find_new_releases(versions_to_scan, URL_BASE, 'ocp-dev-preview')) - new_releases.extend(find_new_releases(versions_to_scan, URL_BASE_X86, 'ocp-dev-preview')) + new_releases.extend(find_new_releases(versions_to_scan, url_base_aarch64, 'ocp-dev-preview')) + new_releases.extend(find_new_releases(versions_to_scan, url_base_x86, 'ocp-dev-preview')) if args.rc: - new_releases.extend(find_new_releases(versions_to_scan, URL_BASE, 'ocp')) - new_releases.extend(find_new_releases(versions_to_scan, URL_BASE_X86, 'ocp')) + new_releases.extend(find_new_releases(versions_to_scan, url_base_aarch64, 'ocp')) + new_releases.extend(find_new_releases(versions_to_scan, url_base_x86, 'ocp')) if not new_releases: logging.info("No new releases found.") @@ -194,7 +200,7 @@ def main(): class VersionListParser(html.parser.HTMLParser): """HTMLParser to extract version numbers from the mirror file list pages. - A page like https://mirror.openshift.com/pub/openshift-v4/aarch64/microshift/ocp-dev-preview/ + A page like https://mirror.openshift.com/pub/openshift-v{major}/aarch64/microshift/ocp-dev-preview/ contains HTML like @@ -355,20 +361,25 @@ def publish_candidate_release(new_release, take_action): candidate_number = new_release.candidate_number release_type = new_release.release_type + # Extract major version from product version (e.g., "4" from "4.16.0") + major_version = product_version.split('.')[0] + url_base_x86 = get_mirror_url_base(major_version, 'x86_64') + url_base_aarch64 = get_mirror_url_base(major_version, 'aarch64') + # Set up the release notes preamble with download links preamble = textwrap.dedent(f""" This is a candidate release for {product_version}. See the mirror for build artifacts: - - {URL_BASE_X86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/ - - {URL_BASE}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/ + - {url_base_x86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/ + - {url_base_aarch64}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/ Or add this RPM repository to your x86 systems: ``` [microshift-{product_version}-{candidate_type}-{candidate_number}] name=MicroShift {product_version} EarlyAccess {candidate_type}.{candidate_number} RPMs - baseurl={URL_BASE_X86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/ + baseurl={url_base_x86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/ enabled=1 gpgcheck=0 skip_if_unavailable=0 @@ -379,7 +390,7 @@ def publish_candidate_release(new_release, take_action): ``` [microshift-{product_version}-{candidate_type}-{candidate_number}] name=MicroShift {product_version} EarlyAccess {candidate_type}.{candidate_number} RPMs - baseurl={URL_BASE}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/ + baseurl={url_base_aarch64}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/ enabled=1 gpgcheck=0 skip_if_unavailable=0 diff --git a/scripts/release-notes/gen_gh_releases_from_rhocp.py b/scripts/release-notes/gen_gh_releases_from_rhocp.py index f4ca1ca757..8969f32f3d 100755 --- a/scripts/release-notes/gen_gh_releases_from_rhocp.py +++ b/scripts/release-notes/gen_gh_releases_from_rhocp.py @@ -26,7 +26,7 @@ def get_rpm_releases(): """Gets the releases from the released MicroShift RPMs in the RHOCP repositories. """ arch = platform.machine() - _, current_minor = common.get_version_from_makefile() + current_major, current_minor = common.get_version_from_makefile() with dnf.Base() as base: base.read_all_repos() @@ -36,8 +36,10 @@ def get_rpm_releases(): # Enable RHOCP repos starting from 4.14 to the current-2 (inclusive; range() stops before the second argument). # E.g., for 4.21 it's 4.14-4.19 because when 4.21 development started, the 4.20 wasn't released yet. - for minor in range(14, int(current_minor)-1): - repo_id = f"rhocp-4.{minor}-for-rhel-9-{arch}-rpms" + # For major version 5, start from 5.0; for major version 4, start from 4.14. + start_minor = 0 if int(current_major) >= 5 else 14 + for minor in range(start_minor, int(current_minor)-1): + repo_id = f"rhocp-{current_major}.{minor}-for-rhel-9-{arch}-rpms" r = base.repos.get_matching(repo_id) r.enable() logging.info(f'Enabled repo: {r.id} - {r.name}') @@ -48,7 +50,7 @@ def get_rpm_releases(): # Try to add current-1 (continuing example from above, it'd be 4.20). # This is separate because DNF does not query remote repos in order, so enabling not active repo can derail whole cache update. try: - r = base.repos.get(f"rhocp-4.{int(current_minor)-1}-for-rhel-9-{arch}-rpms") + r = base.repos.get(f"rhocp-{current_major}.{int(current_minor)-1}-for-rhel-9-{arch}-rpms") r.enable() logging.info(f'Enabled repo: {r.id} - {r.name}') base.fill_sack() diff --git a/test/assets/common_versions.sh.template b/test/assets/common_versions.sh.template index 08a97db286..00b6a87b50 100644 --- a/test/assets/common_versions.sh.template +++ b/test/assets/common_versions.sh.template @@ -68,11 +68,14 @@ get_vrel_from_rpm() {{ echo "" }} -# The current release minor version (e.g. '17' for '4.17') affects +# The current release version (e.g. '4.17') affects # the definition of previous and fake next versions. +export MAJOR_VERSION={major_version} export MINOR_VERSION={minor_version} -export PREVIOUS_MINOR_VERSION=$(( "${{MINOR_VERSION}}" - 1 )) -export YMINUS2_MINOR_VERSION=$(( "${{MINOR_VERSION}}" - 2 )) +export PREVIOUS_MAJOR_VERSION={previous_major_version} +export PREVIOUS_MINOR_VERSION={previous_minor_version} +export YMINUS2_MAJOR_VERSION={yminus2_major_version} +export YMINUS2_MINOR_VERSION={yminus2_minor_version} export FAKE_NEXT_MINOR_VERSION=$(( "${{MINOR_VERSION}}" + 1 )) # For a main branch, the current release repository usually comes from @@ -110,27 +113,34 @@ YMINUS2_RELEASE_VERSION="{yminus2_release_version}" export YMINUS2_RELEASE_REPO export YMINUS2_RELEASE_VERSION -# The 'rhocp_minor_y' variable should be the minor version number, if the -# current release is available through the 'rhocp' stream, otherwise empty. +# The 'rhocp_major_y' and 'rhocp_minor_y' variables should be the major and minor +# version numbers, if the current release is available through the 'rhocp' stream, +# otherwise empty. +RHOCP_MAJOR_Y={rhocp_major_y} RHOCP_MINOR_Y={rhocp_minor_y} # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. If the mirror for current minor is not # available yet, it should point to an older release. RHOCP_MINOR_Y_BETA="{rhocp_minor_y_beta}" +export RHOCP_MAJOR_Y export RHOCP_MINOR_Y export RHOCP_MINOR_Y_BETA -# The 'rhocp_minor_y' variable should be the previous minor version number, if -# the previous release is available through the 'rhocp' stream, otherwise empty. +# The 'rhocp_major_y1' and 'rhocp_minor_y1' variables should be the previous major +# and minor version numbers, if the previous release is available through the +# 'rhocp' stream, otherwise empty. +RHOCP_MAJOR_Y1={rhocp_major_y1} RHOCP_MINOR_Y1={rhocp_minor_y1} # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. The mirror for previous release should always # be available. RHOCP_MINOR_Y1_BETA="{rhocp_minor_y1_beta}" +export RHOCP_MAJOR_Y1 export RHOCP_MINOR_Y1 export RHOCP_MINOR_Y1_BETA -# The 'rhocp_minor_y2' should always be the y-2 minor version number. +# The 'rhocp_major_y2' and 'rhocp_minor_y2' should always be the y-2 version numbers. +export RHOCP_MAJOR_Y2={rhocp_major_y2} export RHOCP_MINOR_Y2={rhocp_minor_y2} export CNCF_SONOBUOY_VERSION={CNCF_SONOBUOY_VERSION} @@ -142,12 +152,12 @@ export CNCF_SYSTEMD_LOGS_VERSION={CNCF_SYSTEMD_LOGS_VERSION} export GITOPS_VERSION={GITOPS_VERSION} # The brew release versions needed for release regression testing -BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{MINOR_VERSION}}-zstream/{ARCH}/")" -BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{PREVIOUS_MINOR_VERSION}}-zstream/{ARCH}/")" -BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{YMINUS2_MINOR_VERSION}}-zstream/{ARCH}/")" -BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{MINOR_VERSION}}-rc/{ARCH}/")" -BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{MINOR_VERSION}}-ec/{ARCH}/")" -BREW_NIGHTLY_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/4.${{MINOR_VERSION}}-nightly/{ARCH}/")" +BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{MAJOR_VERSION}}.${{MINOR_VERSION}}-zstream/{ARCH}/")" +BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{PREVIOUS_MAJOR_VERSION}}.${{PREVIOUS_MINOR_VERSION}}-zstream/{ARCH}/")" +BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{YMINUS2_MAJOR_VERSION}}.${{YMINUS2_MINOR_VERSION}}-zstream/{ARCH}/")" +BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{MAJOR_VERSION}}.${{MINOR_VERSION}}-rc/{ARCH}/")" +BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{MAJOR_VERSION}}.${{MINOR_VERSION}}-ec/{ARCH}/")" +BREW_NIGHTLY_RELEASE_VERSION="$(get_vrel_from_rpm "${{BREW_RPM_SOURCE}}/${{MAJOR_VERSION}}.${{MINOR_VERSION}}-nightly/{ARCH}/")" export BREW_Y0_RELEASE_VERSION export BREW_Y1_RELEASE_VERSION export BREW_Y2_RELEASE_VERSION @@ -169,7 +179,7 @@ fi export BREW_LREL_RELEASE_VERSION # Branch and commit for the openshift-tests-private repository -OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-4.${{MINOR_VERSION}}" +OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-${{MAJOR_VERSION}}.${{MINOR_VERSION}}" OPENSHIFT_TESTS_PRIVATE_REPO_COMMIT="ed0dc50bfaf9b301d175b7035b8c0192ab113db9" export OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH export OPENSHIFT_TESTS_PRIVATE_REPO_COMMIT diff --git a/test/bin/build_rpms.sh b/test/bin/build_rpms.sh index c4c343ae52..1bd5878f81 100755 --- a/test/bin/build_rpms.sh +++ b/test/bin/build_rpms.sh @@ -121,12 +121,12 @@ download_brew_rpms() { rm -rf "${BREW_RPM_SOURCE}" # Run the download procedure bash -x "${SCRIPTDIR}/../../scripts/fetch_tools.sh" brew - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${PREVIOUS_MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${YMINUS2_MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "rc" || true - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "ec" || true - bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "4.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "nightly" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${MAJOR_VERSION}.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${PREVIOUS_MAJOR_VERSION}.${PREVIOUS_MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${YMINUS2_MAJOR_VERSION}.${YMINUS2_MINOR_VERSION}" "${BREW_RPM_SOURCE}" "zstream" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${MAJOR_VERSION}.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "rc" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${MAJOR_VERSION}.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "ec" || true + bash -x "${SCRIPTDIR}/manage_brew_rpms.sh" download "${MAJOR_VERSION}.${MINOR_VERSION}" "${BREW_RPM_SOURCE}" "nightly" || true else echo "WARNING: The Brew Hub site is not accessible, skipping the download" fi diff --git a/test/bin/common.sh b/test/bin/common.sh index 7155c21eb2..3bd040d59e 100644 --- a/test/bin/common.sh +++ b/test/bin/common.sh @@ -229,7 +229,7 @@ get_build_branch() { } # The branch identifier of the current scenario repository, -# i.e. "main", "release-4.14", etc. +# i.e. "main", "release-4.14", "release-5.0", etc. # Used for top-level directory names when caching build artifacts, # i.e. / # shellcheck disable=SC2034 # used elsewhere diff --git a/test/bin/common_versions.sh b/test/bin/common_versions.sh index 3fe35ee99d..bc9a2bc6b2 100644 --- a/test/bin/common_versions.sh +++ b/test/bin/common_versions.sh @@ -68,11 +68,14 @@ get_vrel_from_rpm() { echo "" } -# The current release minor version (e.g. '17' for '4.17') affects +# The current release version (e.g. '4.17') affects # the definition of previous and fake next versions. +export MAJOR_VERSION=4 export MINOR_VERSION=22 -export PREVIOUS_MINOR_VERSION=$(( "${MINOR_VERSION}" - 1 )) -export YMINUS2_MINOR_VERSION=$(( "${MINOR_VERSION}" - 2 )) +export PREVIOUS_MAJOR_VERSION=4 +export PREVIOUS_MINOR_VERSION=21 +export YMINUS2_MAJOR_VERSION=4 +export YMINUS2_MINOR_VERSION=20 export FAKE_NEXT_MINOR_VERSION=$(( "${MINOR_VERSION}" + 1 )) # For a main branch, the current release repository usually comes from @@ -110,27 +113,34 @@ YMINUS2_RELEASE_VERSION="$(get_vrel_from_rhsm "${YMINUS2_RELEASE_REPO}")" export YMINUS2_RELEASE_REPO export YMINUS2_RELEASE_VERSION -# The 'rhocp_minor_y' variable should be the minor version number, if the -# current release is available through the 'rhocp' stream, otherwise empty. +# The 'rhocp_major_y' and 'rhocp_minor_y' variables should be the major and minor +# version numbers, if the current release is available through the 'rhocp' stream, +# otherwise empty. +RHOCP_MAJOR_Y="" RHOCP_MINOR_Y="" # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. If the mirror for current minor is not # available yet, it should point to an older release. RHOCP_MINOR_Y_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.22-el9-beta" +export RHOCP_MAJOR_Y export RHOCP_MINOR_Y export RHOCP_MINOR_Y_BETA -# The 'rhocp_minor_y' variable should be the previous minor version number, if -# the previous release is available through the 'rhocp' stream, otherwise empty. +# The 'rhocp_major_y1' and 'rhocp_minor_y1' variables should be the previous major +# and minor version numbers, if the previous release is available through the +# 'rhocp' stream, otherwise empty. +RHOCP_MAJOR_Y1=4 RHOCP_MINOR_Y1=21 # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. The mirror for previous release should always # be available. RHOCP_MINOR_Y1_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.21-el9-beta" +export RHOCP_MAJOR_Y1 export RHOCP_MINOR_Y1 export RHOCP_MINOR_Y1_BETA -# The 'rhocp_minor_y2' should always be the y-2 minor version number. +# The 'rhocp_major_y2' and 'rhocp_minor_y2' should always be the y-2 version numbers. +export RHOCP_MAJOR_Y2=4 export RHOCP_MINOR_Y2=20 export CNCF_SONOBUOY_VERSION=v0.57.3 @@ -142,12 +152,12 @@ export CNCF_SYSTEMD_LOGS_VERSION=v0.4 export GITOPS_VERSION=1.19 # The brew release versions needed for release regression testing -BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-zstream/${UNAME_M}/")" -BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${PREVIOUS_MINOR_VERSION}-zstream/${UNAME_M}/")" -BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${YMINUS2_MINOR_VERSION}-zstream/${UNAME_M}/")" -BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-rc/${UNAME_M}/")" -BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-ec/${UNAME_M}/")" -BREW_NIGHTLY_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/4.${MINOR_VERSION}-nightly/${UNAME_M}/")" +BREW_Y0_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${MAJOR_VERSION}.${MINOR_VERSION}-zstream/${UNAME_M}/")" +BREW_Y1_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${PREVIOUS_MAJOR_VERSION}.${PREVIOUS_MINOR_VERSION}-zstream/${UNAME_M}/")" +BREW_Y2_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${YMINUS2_MAJOR_VERSION}.${YMINUS2_MINOR_VERSION}-zstream/${UNAME_M}/")" +BREW_RC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${MAJOR_VERSION}.${MINOR_VERSION}-rc/${UNAME_M}/")" +BREW_EC_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${MAJOR_VERSION}.${MINOR_VERSION}-ec/${UNAME_M}/")" +BREW_NIGHTLY_RELEASE_VERSION="$(get_vrel_from_rpm "${BREW_RPM_SOURCE}/${MAJOR_VERSION}.${MINOR_VERSION}-nightly/${UNAME_M}/")" export BREW_Y0_RELEASE_VERSION export BREW_Y1_RELEASE_VERSION export BREW_Y2_RELEASE_VERSION @@ -169,7 +179,7 @@ fi export BREW_LREL_RELEASE_VERSION # Branch and commit for the openshift-tests-private repository -OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-4.${MINOR_VERSION}" +OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH="release-${MAJOR_VERSION}.${MINOR_VERSION}" OPENSHIFT_TESTS_PRIVATE_REPO_COMMIT="ed0dc50bfaf9b301d175b7035b8c0192ab113db9" export OPENSHIFT_TESTS_PRIVATE_REPO_BRANCH export OPENSHIFT_TESTS_PRIVATE_REPO_COMMIT diff --git a/test/bin/pyutils/build_bootc_images.py b/test/bin/pyutils/build_bootc_images.py index b6a3b523fb..6f22e1816e 100644 --- a/test/bin/pyutils/build_bootc_images.py +++ b/test/bin/pyutils/build_bootc_images.py @@ -68,10 +68,20 @@ def find_latest_rpm(repo_path, version=""): return rpms[-1] -def is_rhocp_available(ver): +def is_rhocp_available(major, minor): + """ + Check if the RHOCP repository is available for the specified version. + + Args: + major (int or str): The major version number. + minor (int or str): The minor version number. + + Returns: + bool: True if the repository is available, False otherwise. + """ # Equivalent to `uname -m` architecture = platform.machine() - repository = f"rhocp-4.{ver}-for-rhel-9-{architecture}-rpms" + repository = f"rhocp-{major}.{minor}-for-rhel-9-{architecture}-rpms" try: # Run the dnf command to check for cri-o in the specified repository @@ -82,9 +92,19 @@ def is_rhocp_available(ver): return False -def get_rhocp_beta_url_if_available(ver): - url_amd = f"https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.{ver}-el9-beta/" - url_arm = f"https://mirror.openshift.com/pub/openshift-v4/aarch64/dependencies/rpms/4.{ver}-el9-beta/" +def get_rhocp_beta_url_if_available(major, minor): + """ + Get the RHOCP beta URL if available for the specified version. + + Args: + major (int or str): The major version number. + minor (int or str): The minor version number. + + Returns: + str: The beta URL if available, otherwise empty string. + """ + url_amd = f"https://mirror.openshift.com/pub/openshift-v{major}/x86_64/dependencies/rpms/{major}.{minor}-el9-beta/" + url_arm = f"https://mirror.openshift.com/pub/openshift-v{major}/aarch64/dependencies/rpms/{major}.{minor}-el9-beta/" try: # Run the dnf command to check for cri-o in the specified repository @@ -96,7 +116,7 @@ def get_rhocp_beta_url_if_available(ver): # Use specific minor version RHOCP mirror only if both arches are available. architecture = platform.machine() - return f"https://mirror.openshift.com/pub/openshift-v4/{architecture}/dependencies/rpms/4.{ver}-el9-beta/" + return f"https://mirror.openshift.com/pub/openshift-v{major}/{architecture}/dependencies/rpms/{major}.{minor}-el9-beta/" except Exception: return "" diff --git a/test/bin/pyutils/generate_common_versions.py b/test/bin/pyutils/generate_common_versions.py index 4a076250c4..7d61d5a200 100755 --- a/test/bin/pyutils/generate_common_versions.py +++ b/test/bin/pyutils/generate_common_versions.py @@ -18,6 +18,12 @@ ARCH = os.uname().machine +# Version map defining the last minor version for each major version. +# Used for cross-major Y-1/Y-2 calculations (e.g., 5.0's Y-1 is 4.18). +VERSION_MAP = { + 4: {'last_minor': 18} +} + # The version of Sonobuoy package used in CNCF tests. # See https://github.com/vmware-tanzu/sonobuoy/releases. CNCF_SONOBUOY_VERSION = "v0.57.3" @@ -33,11 +39,39 @@ ) -def get_candidate_repo_url(minor, dev_preview=False): +def get_previous_version(major, minor): + """ + Calculate the previous version (Y-1) handling cross-major boundaries. + + When minor > 0, the previous version is simply (major, minor-1). + When minor == 0, the previous version crosses to the prior major, + using VERSION_MAP to determine the last minor of that major. + + Args: + major (int): The major version number. + minor (int): The minor version number. + + Returns: + tuple: (previous_major, previous_minor) version numbers. + + Raises: + KeyError: If the previous major version is not defined in VERSION_MAP. + """ + if minor > 0: + return (major, minor - 1) + prev_major = major - 1 + if prev_major not in VERSION_MAP: + raise KeyError(f"Major version {prev_major} not found in VERSION_MAP. " + f"Please add it with the last minor version.") + return (prev_major, VERSION_MAP[prev_major]['last_minor']) + + +def get_candidate_repo_url(major, minor, dev_preview=False): """ Get the URL of the engineering or release candidate repository. Args: + major (int): The major version, e.g., 4 or 5. minor (int): The minor version, e.g., 19 for version 4.19. dev_preview (bool): If True, return the engineering candidate repo URL; otherwise, return the release candidate repo URL. @@ -45,34 +79,41 @@ def get_candidate_repo_url(minor, dev_preview=False): Returns: str: The URL of the candidate repository. """ - return f"https://mirror.openshift.com/pub/openshift-v4/{ARCH}/microshift/ocp{'-dev-preview' if dev_preview else ''}/latest-4.{minor}/el9/os" + return f"https://mirror.openshift.com/pub/openshift-v{major}/{ARCH}/microshift/ocp{'-dev-preview' if dev_preview else ''}/latest-{major}.{minor}/el9/os" -def get_dependencies_repo_url(minor, steps_back=0): +def get_dependencies_repo_url(major, minor, steps_back=0): """ - Get the URL of the beta repository for the specified minor version. + Get the URL of the beta repository for the specified version. This function constructs and checks the beta repository URL for the given - minor version (e.g., 4.19). If the repository does not exist or does not + version (e.g., 4.19 or 5.0). If the repository does not exist or does not provide the required packages, it searches previous minor versions—up to - `steps_back` times—until a valid repository is found. + `steps_back` times—until a valid repository is found. When crossing major + version boundaries (e.g., from 5.0 to 4.18), it uses VERSION_MAP. Args: + major (int): The major version, e.g., 4 or 5. minor (int): The minor version, e.g., 19 for version 4.19. - steps_back (int, optional): How many previous minor versions to try + steps_back (int, optional): How many previous versions to try if the current version is unavailable. Defaults to 0. Returns: str or None: The URL of a valid beta repository, or None if none are found. """ - logging.info(f"Getting beta dependencies repository for 4.{minor}, max. {steps_back} previous minors") + logging.info(f"Getting beta dependencies repository for {major}.{minor}, max. {steps_back} previous versions") - for i in range(minor, minor-steps_back-1, -1): - url = f"https://mirror.openshift.com/pub/openshift-v4/{ARCH}/dependencies/rpms/4.{i}-el9-beta" + current_major, current_minor = major, minor + for _ in range(steps_back + 1): + url = f"https://mirror.openshift.com/pub/openshift-v{current_major}/{ARCH}/dependencies/rpms/{current_major}.{current_minor}-el9-beta" if mirror_exists(url) and repo_provides_pkg(url, "cri-o"): - logging.info(f"Beta dependencies repository found for 4.{i}") + logging.info(f"Beta dependencies repository found for {current_major}.{current_minor}") return url - logging.info(f"Beta dependencies repository for 4.{i} not found{', trying older minor' if i>minor-steps_back else ''}") + logging.info(f"Beta dependencies repository for {current_major}.{current_minor} not found, trying older version") + try: + current_major, current_minor = get_previous_version(current_major, current_minor) + except KeyError: + break return None @@ -124,20 +165,21 @@ def mirror_exists(repo_url): return True -def get_subscription_repo_name_if_exists(minor): +def get_subscription_repo_name_if_exists(major, minor): """ - Get the name of the subscription repository for the specified minor version. + Get the name of the subscription repository for the specified version. If the repository provides the microshift package, return the repository name; otherwise, return None. Args: + major (int): The major version, e.g., 4 or 5. minor (int): The minor version, e.g., 19 for 4.19. Returns: str or None: The name of the subscription repository, or None if not available. """ - repo = f"rhocp-4.{minor}-for-rhel-9-{ARCH}-rpms" + repo = f"rhocp-{major}.{minor}-for-rhel-9-{ARCH}-rpms" if repo_provides_pkg(repo, "microshift"): return repo @@ -145,37 +187,38 @@ def get_subscription_repo_name_if_exists(minor): return None -def get_microshift_repo(minor): +def get_microshift_repo(major, minor): """ - Get the repository for the specified minor version. + Get the repository for the specified version. This function searches for a repository that provides the microshift package - for the given minor version. It checks the 'rhocp' stream, then release + for the given version. It checks the 'rhocp' stream, then release candidate (RC), and finally engineering candidate (EC) repositories—in that order. If none are available, it returns empty string. Args: + major (int): The major version, e.g., 4 or 5. minor (int): The minor version, e.g., 19 for 4.19. Returns: str: The repository name or URL if found, otherwise None. """ - repo = get_subscription_repo_name_if_exists(minor) + repo = get_subscription_repo_name_if_exists(major, minor) if repo is not None: - logging.info(f"Found subscription repository for 4.{minor}") + logging.info(f"Found subscription repository for {major}.{minor}") return repo - rc = get_candidate_repo_url(minor, dev_preview=False) + rc = get_candidate_repo_url(major, minor, dev_preview=False) if mirror_exists(rc) and repo_provides_pkg(rc, "microshift"): - logging.info(f"Found release candidate for 4.{minor}") + logging.info(f"Found release candidate for {major}.{minor}") return rc - ec = get_candidate_repo_url(minor, dev_preview=True) + ec = get_candidate_repo_url(major, minor, dev_preview=True) if mirror_exists(ec) and repo_provides_pkg(ec, "microshift"): - logging.info(f"Found engineering candidate for 4.{minor}") + logging.info(f"Found engineering candidate for {major}.{minor}") return ec - logging.info(f"No repository found for 4.{minor}") + logging.info(f"No repository found for {major}.{minor}") return "" @@ -238,53 +281,56 @@ def get_gitops_version(minor_version): return gitops_version_number return "" - -def generate_common_versions(minor_version): - previous_minor_version = minor_version - 1 - yminus2_minor_version = minor_version - 2 +def generate_common_versions(major_version, minor_version): + # Calculate previous versions using cross-major version logic + previous_major_version, previous_minor_version = get_previous_version(major_version, minor_version) + yminus2_major_version, yminus2_minor_version = get_previous_version(previous_major_version, previous_minor_version) # The current release repository comes from the 'rhocp' stream for release # branches, or the OpenShift mirror if only a RC or EC is available. It can # be empty, if no candidate for the current minor has been built yet. logging.info("Getting CURRENT_RELEASE_REPO") - current_release_repo = get_microshift_repo(minor_version) + current_release_repo = get_microshift_repo(major_version, minor_version) current_release_version = get_release_version_string(current_release_repo, "CURRENT_RELEASE_REPO") # The previous release repository value should either point to the OpenShift # mirror URL or the 'rhocp' repository name. logging.info("Getting PREVIOUS_RELEASE_REPO") - previous_release_repo = get_microshift_repo(previous_minor_version) + previous_release_repo = get_microshift_repo(previous_major_version, previous_minor_version) previous_release_version = get_release_version_string(previous_release_repo, "PREVIOUS_RELEASE_REPO") # The y-2 release repository value should either point to the OpenShift # mirror URL or the 'rhocp' repository name. It should always come from # the 'rhocp' stream. logging.info("Getting YMINUS2_RELEASE_REPO") - yminus2_release_repo = get_microshift_repo(yminus2_minor_version) + yminus2_release_repo = get_microshift_repo(yminus2_major_version, yminus2_minor_version) yminus2_release_version = get_release_version_string(yminus2_release_repo, "YMINUS2_RELEASE_REPO") # The 'rhocp_minor_y' variable should be the minor version number, if the # current release is available through the 'rhocp' stream, otherwise empty. - rhocp_minor_y = minor_version if repo_provides_pkg(f"rhocp-4.{minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""' + rhocp_minor_y = minor_version if repo_provides_pkg(f"rhocp-{major_version}.{minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""' + rhocp_major_y = major_version if rhocp_minor_y != '""' else '""' # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. If the mirror for current minor is not # available yet, it should point to an older release. logging.info("Getting RHOCP_MINOR_Y_BETA") - rhocp_minor_y_beta = get_dependencies_repo_url(minor_version, 3) + rhocp_minor_y_beta = get_dependencies_repo_url(major_version, minor_version, 3) - # The 'rhocp_minor_y' variable should be the previous minor version number, if + # The 'rhocp_minor_y1' variable should be the previous minor version number, if # the previous release is available through the 'rhocp' stream, otherwise empty. - rhocp_minor_y1 = previous_minor_version if repo_provides_pkg(f"rhocp-4.{previous_minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""' + rhocp_minor_y1 = previous_minor_version if repo_provides_pkg(f"rhocp-{previous_major_version}.{previous_minor_version}-for-rhel-9-{ARCH}-rpms", "cri-o") else '""' + rhocp_major_y1 = previous_major_version if rhocp_minor_y1 != '""' else '""' # The beta repository, containing dependencies, should point to the # OpenShift mirror URL. The mirror for previous release should always # be available. logging.info("Getting RHOCP_MINOR_Y1_BETA") - rhocp_minor_y1_beta = get_dependencies_repo_url(previous_minor_version) + rhocp_minor_y1_beta = get_dependencies_repo_url(previous_major_version, previous_minor_version) # The 'rhocp_minor_y2' should always be the y-2 minor version number. rhocp_minor_y2 = yminus2_minor_version + rhocp_major_y2 = yminus2_major_version # The current version of the microshift-gitops package. logging.info("Getting GITOPS_VERSION") @@ -296,17 +342,25 @@ def generate_common_versions(minor_version): template_string = f.read() output = template_string.format( + major_version=major_version, minor_version=minor_version, + previous_major_version=previous_major_version, + previous_minor_version=previous_minor_version, + yminus2_major_version=yminus2_major_version, + yminus2_minor_version=yminus2_minor_version, current_release_repo=current_release_repo, current_release_version=current_release_version, previous_release_repo=previous_release_repo, previous_release_version=previous_release_version, yminus2_release_repo=yminus2_release_repo, yminus2_release_version=yminus2_release_version, + rhocp_major_y=rhocp_major_y, rhocp_minor_y=rhocp_minor_y, rhocp_minor_y_beta=rhocp_minor_y_beta, + rhocp_major_y1=rhocp_major_y1, rhocp_minor_y1=rhocp_minor_y1, rhocp_minor_y1_beta=rhocp_minor_y1_beta, + rhocp_major_y2=rhocp_major_y2, rhocp_minor_y2=rhocp_minor_y2, CNCF_SONOBUOY_VERSION=CNCF_SONOBUOY_VERSION, CNCF_SYSTEMD_LOGS_VERSION=CNCF_SYSTEMD_LOGS_VERSION, @@ -321,6 +375,7 @@ def generate_common_versions(minor_version): def main(): parser = argparse.ArgumentParser(description="Generate common_versions.sh variables.") + parser.add_argument("--major", type=int, default=4, help="The major version number (default: 4).") parser.add_argument("minor", type=int, help="The minor version number.") parser.add_argument("--update-file", default=False, action="store_true", help="Update test/bin/common_versions.sh file.") parser.add_argument("--create-pr", default=False, action="store_true", @@ -329,7 +384,7 @@ def main(): parser.add_argument("--dry-run", default=False, action="store_true", help="Dry run") args = parser.parse_args() - output = generate_common_versions(args.minor) + output = generate_common_versions(args.major, args.minor) if args.update_file or args.create_pr: logging.info("Updating test/bin/common_versions.sh file") @@ -346,8 +401,8 @@ def main(): exit(0) base_branch = g.git_repo.active_branch.name - if not base_branch.startswith("release-4"): - logging.error(f"Script is expected to be executed on branch starting with 'release-4', but it's {base_branch}") + if not base_branch.startswith(f"release-{args.major}"): + logging.error(f"Script is expected to be executed on branch starting with 'release-{args.major}', but it's {base_branch}") exit(1) gh = ghutils.GithubUtils(dry_run=args.dry_run) @@ -360,7 +415,7 @@ def main(): pull_req = gh.get_existing_pr_for_a_branch(base_branch, new_branch_name) if pull_req is None: - # Assuming the script always runs against `release-4.y` branch for the value in brackets. + # Assuming the script always runs against `release-X.y` branch for the value in brackets. pr_title = f"[{base_branch}] NO-ISSUE: Update common_versions.sh" gh.create_pr(base_branch, new_branch_name, pr_title, "") diff --git a/test/bin/scenario.sh b/test/bin/scenario.sh index 8f16e22d8f..01845e2643 100755 --- a/test/bin/scenario.sh +++ b/test/bin/scenario.sh @@ -439,6 +439,7 @@ prepare_kickstart() { -e "s|REPLACE_OSTREE_SERVER_URL|${WEB_SERVER_URL}/repo|g" \ -e "s|REPLACE_BOOTC_REGISTRY_URL|${MIRROR_REGISTRY_URL}|g" \ -e "s|REPLACE_RPM_SERVER_URL|${WEB_SERVER_URL}/rpm-repos|g" \ + -e "s|REPLACE_MAJOR_VERSION|${MAJOR_VERSION}|g" \ -e "s|REPLACE_MINOR_VERSION|${MINOR_VERSION}|g" \ -e "s|REPLACE_BOOT_COMMIT_REF|${boot_commit_ref}|g" \ -e "s|REPLACE_PULL_SECRET|${PULL_SECRET_CONTENT}|g" \ diff --git a/test/kickstart-templates/includes/post-cos9rpm.cfg b/test/kickstart-templates/includes/post-cos9rpm.cfg index deef0472a9..d170c8a97e 100644 --- a/test/kickstart-templates/includes/post-cos9rpm.cfg +++ b/test/kickstart-templates/includes/post-cos9rpm.cfg @@ -22,12 +22,14 @@ EOF # openshift-client and crio from OpenShift Mirror. # Excludes all to avoid unintentionally sourcing packages from here that # should come from a centos repos. -OCPVERSION=4.REPLACE_MINOR_VERSION +OCPMAJOR=REPLACE_MAJOR_VERSION +OCPMINOR=REPLACE_MINOR_VERSION +OCPVERSION="${OCPMAJOR}.${OCPMINOR}" OCPREPO="openshift-${OCPVERSION}-mirror" cat > "/etc/yum.repos.d/${OCPREPO}.repo" </dev/null </dev/null </dev/null </dev/null <