Skip to content

Commit 685552c

Browse files
Merge pull request #6372 from pacevedom/test-framework-5.0
USHIFT-6718: major version changes for test framework
2 parents d81e060 + c66275f commit 685552c

32 files changed

Lines changed: 429 additions & 200 deletions

scripts/auto-rebase/rebase_history.sh

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,26 @@ show_details() {
2222
echo
2323
}
2424

25-
SOURCE_VERSION=$(awk '{print $3}' Makefile.version.aarch64.var | cut -f1 -d-)
26-
MINOR_VERSION=$(echo "${SOURCE_VERSION}" | cut -f2 -d.)
27-
PREVIOUS_MINOR_VERSION=$(( "${MINOR_VERSION}" - 1 ))
28-
PREVIOUS_RELEASE_BRANCH="origin/release-4.${PREVIOUS_MINOR_VERSION}"
25+
SOURCE_VERSION=$(grep '^OCP_VERSION' Makefile.version.aarch64.var | cut -d'=' -f2 | tr -d ' ' | cut -d'-' -f1)
26+
MAJOR_VERSION=$(echo "${SOURCE_VERSION}" | cut -d'.' -f1)
27+
MINOR_VERSION=$(echo "${SOURCE_VERSION}" | cut -d'.' -f2)
28+
29+
# Calculate previous version, handling cross-major boundaries (e.g., 5.0 -> 4.22)
30+
if (( MINOR_VERSION > 0 )); then
31+
PREVIOUS_MAJOR_VERSION="${MAJOR_VERSION}"
32+
PREVIOUS_MINOR_VERSION=$(( MINOR_VERSION - 1 ))
33+
else
34+
# Cross-major boundary: map of last minor version for each major
35+
declare -A LAST_MINOR_FOR_MAJOR=([4]=22)
36+
PREVIOUS_MAJOR_VERSION=$(( MAJOR_VERSION - 1 ))
37+
PREVIOUS_MINOR_VERSION="${LAST_MINOR_FOR_MAJOR[${PREVIOUS_MAJOR_VERSION}]:-}"
38+
if [[ -z "${PREVIOUS_MINOR_VERSION}" ]]; then
39+
echo "ERROR: No last minor version defined for major ${PREVIOUS_MAJOR_VERSION}" >&2
40+
exit 1
41+
fi
42+
fi
43+
44+
PREVIOUS_RELEASE_BRANCH="origin/release-${PREVIOUS_MAJOR_VERSION}.${PREVIOUS_MINOR_VERSION}"
2945
FIRST_RELEASE_COMMIT=$(branch_start "${PREVIOUS_RELEASE_BRANCH}")
3046

3147
mkdir -p _output
@@ -36,7 +52,7 @@ COMMIT_LIST=_output/commit_list.txt
3652
echo "Getting the list of changes since ${PREVIOUS_RELEASE_BRANCH} was created..."
3753
git log --date-order --reverse --pretty=format:"%H %s" "${FIRST_RELEASE_COMMIT}"..origin/main scripts/auto-rebase/changelog.txt >"${COMMIT_LIST}"
3854

39-
HISTORY_FILE="_output/rebase_history_4_${MINOR_VERSION}.txt"
55+
HISTORY_FILE="_output/rebase_history_${MAJOR_VERSION}_${MINOR_VERSION}.txt"
4056
rm -f "${HISTORY_FILE}"
4157
# shellcheck disable=SC2162
4258
while read commit summary; do

scripts/devenv-builder/configure-vm.sh

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,29 +193,56 @@ function configure_rhel_subscription() {
193193
function configure_rhel_repositories() {
194194
sudo subscription-manager config --rhsm.manage_repos=1
195195

196+
# Extract major version from Makefile.version
197+
local -r ocp_major="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)"
198+
199+
# Map of last minor version for each major (for cross-major transitions)
200+
local -A last_minor_for_major=([4]=22)
201+
202+
# Calculate previous version handling cross-major boundaries
203+
# Sets prev_major and prev_minor variables
204+
get_prev_version() {
205+
local major=$1
206+
local minor=$2
207+
if (( minor > 0 )); then
208+
prev_major="${major}"
209+
prev_minor=$(( minor - 1 ))
210+
else
211+
prev_major=$(( major - 1 ))
212+
prev_minor="${last_minor_for_major[${prev_major}]:-}"
213+
fi
214+
}
215+
196216
RHOCP=$("${RHOCP_REPO}")
197-
if [[ "${RHOCP}" =~ ^[0-9]{2} ]]; then
198-
sudo subscription-manager repos --enable "rhocp-4.${RHOCP}-for-rhel-9-$(uname -m)-rpms"
217+
if [[ "${RHOCP}" =~ ^[0-9]{1,2}$ ]]; then
218+
sudo subscription-manager repos --enable "rhocp-${ocp_major}.${RHOCP}-for-rhel-9-$(uname -m)-rpms"
199219
elif [[ "${RHOCP}" =~ ^http ]]; then
200220
url=$(echo "${RHOCP}" | cut -d, -f1)
201221
ver=$(echo "${RHOCP}" | cut -d, -f2)
202-
OCP_REPO_NAME="rhocp-4.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms"
222+
OCP_REPO_NAME="rhocp-${ocp_major}.${ver}-for-rhel-9-mirrorbeta-$(uname -i)-rpms"
203223
sudo tee "/etc/yum.repos.d/${OCP_REPO_NAME}.repo" >/dev/null <<EOF
204224
[${OCP_REPO_NAME}]
205-
name=Beta rhocp-4.${ver} RPMs for RHEL 9
225+
name=Beta rhocp-${ocp_major}.${ver} RPMs for RHEL 9
206226
baseurl=${url}
207227
enabled=1
208228
gpgcheck=0
209229
skip_if_unavailable=0
210230
EOF
211-
PREVIOUS_RHOCP=$("${RHOCP_REPO}" $((ver-1)))
212-
if [[ "${PREVIOUS_RHOCP}" =~ ^[0-9]{2} ]]; then
213-
sudo subscription-manager repos --enable "rhocp-4.${PREVIOUS_RHOCP}-for-rhel-9-$(uname -m)-rpms"
214-
else
215-
# If RHOCP Y-1 is not available, try RHOCP Y-2.
216-
Y2_RHOCP=$("${RHOCP_REPO}" $((ver-2)))
217-
if [[ "${Y2_RHOCP}" =~ ^[0-9]{2} ]]; then
218-
sudo subscription-manager repos --enable "rhocp-4.${Y2_RHOCP}-for-rhel-9-$(uname -m)-rpms"
231+
# Calculate Y-1 version
232+
get_prev_version "${ocp_major}" "${ver}"
233+
if [[ -n "${prev_minor}" ]]; then
234+
PREVIOUS_RHOCP=$("${RHOCP_REPO}" "${prev_minor}" "${prev_major}")
235+
if [[ "${PREVIOUS_RHOCP}" =~ ^[0-9]{1,2}$ ]]; then
236+
sudo subscription-manager repos --enable "rhocp-${prev_major}.${PREVIOUS_RHOCP}-for-rhel-9-$(uname -m)-rpms"
237+
else
238+
# If RHOCP Y-1 is not available, try RHOCP Y-2.
239+
get_prev_version "${prev_major}" "${prev_minor}"
240+
if [[ -n "${prev_minor}" ]]; then
241+
Y2_RHOCP=$("${RHOCP_REPO}" "${prev_minor}" "${prev_major}")
242+
if [[ "${Y2_RHOCP}" =~ ^[0-9]{1,2}$ ]]; then
243+
sudo subscription-manager repos --enable "rhocp-${prev_major}.${Y2_RHOCP}-for-rhel-9-$(uname -m)-rpms"
244+
fi
245+
fi
219246
fi
220247
fi
221248
fi
@@ -273,9 +300,11 @@ function install_openshift_clients() {
273300
"${DNF_RETRY}" "install" "openshift-clients"
274301
else
275302
# Assume the current development version on non-RHEL OS
276-
OCPVERSION="4.$(cut -d'.' -f2 "${MAKE_VERSION}")"
277-
OCC_SRC="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/${OCPVERSION}-el9-beta"
278-
OCC_RPM="$(curl -s "${OCC_SRC}/" | grep -o "openshift-clients-4[^\"']*.rpm" | sort | uniq)"
303+
OCP_MAJOR="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)"
304+
OCP_MINOR="$(grep '^OCP_VERSION' "${MAKE_VERSION}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f2)"
305+
OCPVERSION="${OCP_MAJOR}.${OCP_MINOR}"
306+
OCC_SRC="https://mirror.openshift.com/pub/openshift-v${OCP_MAJOR}/$(uname -m)/dependencies/rpms/${OCPVERSION}-el9-beta"
307+
OCC_RPM="$(curl -s "${OCC_SRC}/" | grep -o "openshift-clients-${OCP_MAJOR}[^\"']*.rpm" | sort | uniq)"
279308
OCC_LOC="$(mktemp /tmp/openshift-client-XXXXX.rpm)"
280309
OCC_REM="${OCC_SRC}/${OCC_RPM}"
281310

scripts/get-latest-rhocp-repo.sh

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@
88
# because repositories are only usable after the release.
99
# Accessing them before the release results in 403 error.
1010
#
11-
# Script can accept a minor version (e.g. 16) to check for RHOCP of specific version only.
11+
# Script can accept:
12+
# - A minor version (e.g. 16) to check for RHOCP of specific version only.
13+
# - A minor and major version (e.g. 22 4) to check for RHOCP of a specific major.minor.
1214
#
1315
# Output is:
1416
# - just a minor version in case of subscription RHOCP repository, e.g.: 15
1517
# - or an URL to beta mirror followed by comma and minor version, e.g.:
1618
# https://mirror.openshift.com/pub/openshift-v4/x86_64/dependencies/rpms/4.16-el9-beta/,16
19+
# https://mirror.openshift.com/pub/openshift-v5/x86_64/dependencies/rpms/5.0-el9-beta/,0
1720

1821
set -euo pipefail
1922

@@ -25,39 +28,51 @@ if ! sudo subscription-manager status >&/dev/null; then
2528
exit 1
2629
fi
2730

28-
if [[ "$#" -eq 1 ]]; then
31+
# Get version of currently checked out branch.
32+
# It's based on values stored in Makefile.version.$ARCH.var.
33+
make_version="${REPOROOT}/Makefile.version.$(uname -m).var"
34+
if [ ! -f "${make_version}" ] ; then
35+
# Attempt to locate the Makefile version file next to the current script.
36+
# This is necessary when bootstrapping the development environment for the first time.
37+
make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1)
38+
if [ ! -f "${make_version}" ] ; then
39+
>&2 echo "Cannot find the Makefile.version.$(uname -m).var file"
40+
exit 1
41+
fi
42+
fi
43+
if [[ "$#" -ge 2 ]]; then
44+
# Both minor and major provided as arguments
45+
current_minor="${1}"
46+
current_major="${2}"
47+
stop="${current_minor}"
48+
elif [[ "$#" -eq 1 ]]; then
49+
# Only minor provided, get major from Makefile
2950
current_minor="${1}"
51+
current_major=$(grep '^OCP_VERSION' "${make_version}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
3052
stop="${current_minor}"
3153
else
32-
# Get minor version of currently checked out branch.
33-
# It's based on values stored in Makefile.version.$ARCH.var.
34-
make_version="${REPOROOT}/Makefile.version.$(uname -m).var"
35-
if [ ! -f "${make_version}" ] ; then
36-
# Attempt to locate the Makefile version file next to the current script.
37-
# This is necessary when bootstrapping the development environment for the first time.
38-
make_version=$(find "${SCRIPTDIR}" -maxdepth 1 -name "Makefile.version.$(uname -m).*.var" | tail -1)
39-
if [ ! -f "${make_version}" ] ; then
40-
>&2 echo "Cannot find the Makefile.version.$(uname -m).var file"
41-
exit 1
42-
fi
43-
fi
44-
current_minor=$(cut -d'.' -f2 "${make_version}")
54+
# No arguments, get both from Makefile
55+
current_major=$(grep '^OCP_VERSION' "${make_version}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f1)
56+
current_minor=$(grep '^OCP_VERSION' "${make_version}" | cut -d'=' -f2 | tr -d ' ' | cut -d'.' -f2)
4557
stop=$(( current_minor - 3 ))
58+
if (( stop < 0 )); then
59+
stop=0
60+
fi
4661
fi
4762

48-
# Go through minor versions, starting from current_mirror counting down
63+
# Go through minor versions, starting from current_minor counting down
4964
# to get latest available rhocp repository.
50-
# For example, at the time of writing this comment, current_minor is 16,
51-
# and following code will try to access rhocp-4.15 (which is not released yet)
52-
# and then rhocp-4.14 (which will be returned from the script because it's usable).
65+
# For example, if current version is 4.16, the code will try to access
66+
# rhocp-4.15 (which may not be released yet) and then rhocp-4.14 (which
67+
# will be returned if it's usable). Works similarly for version 5.x.
5368
for ver in $(seq "${current_minor}" -1 "${stop}"); do
54-
repository="rhocp-4.${ver}-for-rhel-9-$(uname -m)-rpms"
69+
repository="rhocp-${current_major}.${ver}-for-rhel-9-$(uname -m)-rpms"
5570
if sudo dnf repository-packages --showduplicates "${repository}" info cri-o 1>&2; then
5671
echo "${ver}"
5772
exit 0
5873
fi
5974

60-
rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v4/$(uname -m)/dependencies/rpms/4.${ver}-el9-beta/"
75+
rhocp_beta_url="https://mirror.openshift.com/pub/openshift-v${current_major}/$(uname -m)/dependencies/rpms/${current_major}.${ver}-el9-beta/"
6176
if sudo dnf repository-packages --showduplicates --disablerepo '*' --repofrompath "this,${rhocp_beta_url}" this info cri-o 1>&2; then
6277
echo "${rhocp_beta_url},${ver}"
6378
exit 0

scripts/release-notes/common.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,44 @@ def get_version_from_makefile():
6868
return major, minor
6969

7070

71+
# Map of last minor version for each major version (for cross-major transitions).
72+
# When moving from X.0 to previous version, we need to know X-1's last minor.
73+
LAST_MINOR_FOR_MAJOR = {
74+
4: 22
75+
}
76+
77+
78+
def get_previous_version(major, minor):
79+
"""
80+
Calculate the previous version (Y-1) handling cross-major boundaries.
81+
82+
When minor > 0, the previous version is simply (major, minor-1).
83+
When minor == 0, the previous version crosses to the prior major,
84+
using LAST_MINOR_FOR_MAJOR to determine the last minor of that major.
85+
86+
Args:
87+
major (int or str): The major version number.
88+
minor (int or str): The minor version number.
89+
90+
Returns:
91+
tuple: (previous_major, previous_minor) as strings.
92+
93+
Raises:
94+
KeyError: If the previous major version is not defined in LAST_MINOR_FOR_MAJOR.
95+
"""
96+
major_int = int(major)
97+
minor_int = int(minor)
98+
99+
if minor_int > 0:
100+
return (str(major_int), str(minor_int - 1))
101+
102+
prev_major = major_int - 1
103+
if prev_major not in LAST_MINOR_FOR_MAJOR:
104+
raise KeyError(f"Major version {prev_major} not found in LAST_MINOR_FOR_MAJOR. "
105+
f"Please add it with the last minor version.")
106+
return (str(prev_major), str(LAST_MINOR_FOR_MAJOR[prev_major]))
107+
108+
71109
def redact(input):
72110
if GITHUB_TOKEN == "":
73111
return input

scripts/release-notes/gen_gh_releases_from_mirror.py

Lines changed: 35 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@
6060

6161
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s')
6262

63-
URL_BASE = "https://mirror.openshift.com/pub/openshift-v4/aarch64/microshift"
64-
URL_BASE_X86 = "https://mirror.openshift.com/pub/openshift-v4/x86_64/microshift"
63+
64+
def get_mirror_url_base(major_version, arch):
65+
"""Get the mirror URL base for the given major version and architecture."""
66+
return f"https://mirror.openshift.com/pub/openshift-v{major_version}/{arch}/microshift"
67+
6568

6669
# An EC RPM filename looks like
6770
# microshift-4.13.0~ec.4-202303070857.p0.gcf0bce2.assembly.ec.4.el9.aarch64.rpm
@@ -102,17 +105,18 @@ def main():
102105
# We build a default list of versions to scan using the current
103106
# version and the previous version. This assumes the script is run
104107
# out of the main branch where we can find the most current
105-
# version under development. During the period where 4.n is being
106-
# developed, 4.n-1 may still be producing only release candidates,
108+
# version under development. During the period where X.n is being
109+
# developed, X.n-1 may still be producing only release candidates,
107110
# so that scanning those 2 versions give us the 2 most recent
108111
# candidates for having no releases. During the period where the
109112
# main branch has not landed a rebase to update the version and
110113
# both main and the pre-release branch have the same version, we
111-
# will end up scanning for EC or RC releases of 4.n-2, but that's
114+
# will end up scanning for EC or RC releases of X.n-2, but that's
112115
# OK because the should all have been tagged already.
116+
prev_major, prev_minor = common.get_previous_version(major, minor)
113117
versions_to_scan = [
114118
'.'.join([major, minor]), # this minor version
115-
'.'.join([major, str(int(minor)-1)]), # the previous minor version
119+
'.'.join([prev_major, prev_minor]), # the previous minor version
116120
]
117121

118122
parser = argparse.ArgumentParser(
@@ -167,13 +171,22 @@ def main():
167171
if args.versions_to_scan:
168172
versions_to_scan = args.versions_to_scan
169173

174+
# Group versions by major to use correct mirror URL bases
175+
versions_by_major = {}
176+
for version in versions_to_scan:
177+
scan_major = version.split('.', 1)[0]
178+
versions_by_major.setdefault(scan_major, []).append(version)
179+
170180
new_releases = []
171-
if args.ec:
172-
new_releases.extend(find_new_releases(versions_to_scan, URL_BASE, 'ocp-dev-preview'))
173-
new_releases.extend(find_new_releases(versions_to_scan, URL_BASE_X86, 'ocp-dev-preview'))
174-
if args.rc:
175-
new_releases.extend(find_new_releases(versions_to_scan, URL_BASE, 'ocp'))
176-
new_releases.extend(find_new_releases(versions_to_scan, URL_BASE_X86, 'ocp'))
181+
for scan_major, scan_versions in versions_by_major.items():
182+
url_base_aarch64 = get_mirror_url_base(scan_major, 'aarch64')
183+
url_base_x86 = get_mirror_url_base(scan_major, 'x86_64')
184+
if args.ec:
185+
new_releases.extend(find_new_releases(scan_versions, url_base_aarch64, 'ocp-dev-preview'))
186+
new_releases.extend(find_new_releases(scan_versions, url_base_x86, 'ocp-dev-preview'))
187+
if args.rc:
188+
new_releases.extend(find_new_releases(scan_versions, url_base_aarch64, 'ocp'))
189+
new_releases.extend(find_new_releases(scan_versions, url_base_x86, 'ocp'))
177190

178191
if not new_releases:
179192
logging.info("No new releases found.")
@@ -194,7 +207,7 @@ def main():
194207
class VersionListParser(html.parser.HTMLParser):
195208
"""HTMLParser to extract version numbers from the mirror file list pages.
196209
197-
A page like https://mirror.openshift.com/pub/openshift-v4/aarch64/microshift/ocp-dev-preview/
210+
A page like https://mirror.openshift.com/pub/openshift-v{major}/aarch64/microshift/ocp-dev-preview/
198211
199212
contains HTML like
200213
@@ -355,20 +368,25 @@ def publish_candidate_release(new_release, take_action):
355368
candidate_number = new_release.candidate_number
356369
release_type = new_release.release_type
357370

371+
# Extract major version from product version (e.g., "4" from "4.16.0")
372+
major_version = product_version.split('.')[0]
373+
url_base_x86 = get_mirror_url_base(major_version, 'x86_64')
374+
url_base_aarch64 = get_mirror_url_base(major_version, 'aarch64')
375+
358376
# Set up the release notes preamble with download links
359377
preamble = textwrap.dedent(f"""
360378
This is a candidate release for {product_version}.
361379
362380
See the mirror for build artifacts:
363-
- {URL_BASE_X86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/
364-
- {URL_BASE}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/
381+
- {url_base_x86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/
382+
- {url_base_aarch64}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/
365383
366384
Or add this RPM repository to your x86 systems:
367385
368386
```
369387
[microshift-{product_version}-{candidate_type}-{candidate_number}]
370388
name=MicroShift {product_version} EarlyAccess {candidate_type}.{candidate_number} RPMs
371-
baseurl={URL_BASE_X86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/
389+
baseurl={url_base_x86}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/
372390
enabled=1
373391
gpgcheck=0
374392
skip_if_unavailable=0
@@ -379,7 +397,7 @@ def publish_candidate_release(new_release, take_action):
379397
```
380398
[microshift-{product_version}-{candidate_type}-{candidate_number}]
381399
name=MicroShift {product_version} EarlyAccess {candidate_type}.{candidate_number} RPMs
382-
baseurl={URL_BASE}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/
400+
baseurl={url_base_aarch64}/{release_type}/{product_version}-{candidate_type}.{candidate_number}/el9/os/
383401
enabled=1
384402
gpgcheck=0
385403
skip_if_unavailable=0

0 commit comments

Comments
 (0)