Skip to content

Commit 5137c1b

Browse files
committed
Fix fake_next_minor to cross major versions
1 parent c781b76 commit 5137c1b

8 files changed

Lines changed: 50 additions & 25 deletions

File tree

test/assets/common_versions.sh.template

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,16 @@ export PREVIOUS_MAJOR_VERSION={previous_major_version}
7676
export PREVIOUS_MINOR_VERSION={previous_minor_version}
7777
export YMINUS2_MAJOR_VERSION={yminus2_major_version}
7878
export YMINUS2_MINOR_VERSION={yminus2_minor_version}
79-
export FAKE_NEXT_MINOR_VERSION=$(( "${{MINOR_VERSION}}" + 1 ))
79+
# Handle cross-major version boundary (e.g. 4.22 -> 5.0)
80+
declare -A LAST_MINOR_FOR_MAJOR=({last_minor_for_major_bash})
81+
if [[ -n "${{LAST_MINOR_FOR_MAJOR[${{MAJOR_VERSION}}]:-}}" && \
82+
"${{MINOR_VERSION}}" -eq "${{LAST_MINOR_FOR_MAJOR[${{MAJOR_VERSION}}]}}" ]]; then
83+
export FAKE_NEXT_MAJOR_VERSION=$(( MAJOR_VERSION + 1 ))
84+
export FAKE_NEXT_MINOR_VERSION=0
85+
else
86+
export FAKE_NEXT_MAJOR_VERSION="${{MAJOR_VERSION}}"
87+
export FAKE_NEXT_MINOR_VERSION=$(( "${{MINOR_VERSION}}" + 1 ))
88+
fi
8089

8190
# For a main branch, the current release repository usually comes from
8291
# the OpenShift mirror site, either 'ocp-dev-preview' in the beginning of the

test/bin/build_images.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ rm -f "${CONTAINER_LIST}"
723723
if ${EXTRACT_CONTAINER_IMAGES}; then
724724
extract_container_images "${SOURCE_VERSION}" "${LOCAL_REPO}" "${CONTAINER_LIST}"
725725
# The following images are specific to layers that use fake rpms built from source.
726-
extract_container_images "${MAJOR_VERSION}.${FAKE_NEXT_MINOR_VERSION}.*" "${NEXT_REPO}" "${CONTAINER_LIST}"
726+
extract_container_images "${FAKE_NEXT_MAJOR_VERSION}.${FAKE_NEXT_MINOR_VERSION}.*" "${NEXT_REPO}" "${CONTAINER_LIST}"
727727
extract_container_images "${PREVIOUS_RELEASE_VERSION}" "${PREVIOUS_RELEASE_REPO}" "${CONTAINER_LIST}"
728728
extract_container_images "${YMINUS2_RELEASE_VERSION}" "${YMINUS2_RELEASE_REPO}" "${CONTAINER_LIST}"
729729
# The following images are specific to the brew release versions.

test/bin/common_versions.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,31 @@ get_vrel_from_rpm() {
7070

7171
# The current release version (e.g. '4.17') affects
7272
# the definition of previous and fake next versions.
73-
export MAJOR_VERSION=4
74-
export MINOR_VERSION=22
73+
export MAJOR_VERSION=5
74+
export MINOR_VERSION=0
7575
export PREVIOUS_MAJOR_VERSION=4
76-
export PREVIOUS_MINOR_VERSION=21
76+
export PREVIOUS_MINOR_VERSION=22
7777
export YMINUS2_MAJOR_VERSION=4
78-
export YMINUS2_MINOR_VERSION=20
79-
export FAKE_NEXT_MINOR_VERSION=$(( "${MINOR_VERSION}" + 1 ))
78+
export YMINUS2_MINOR_VERSION=21
79+
# Handle cross-major version boundary (e.g. 4.22 -> 5.0)
80+
declare -A LAST_MINOR_FOR_MAJOR=([4]=22)
81+
if [[ -n "${LAST_MINOR_FOR_MAJOR[${MAJOR_VERSION}]:-}" && \
82+
"${MINOR_VERSION}" -eq "${LAST_MINOR_FOR_MAJOR[${MAJOR_VERSION}]}" ]]; then
83+
export FAKE_NEXT_MAJOR_VERSION=$(( MAJOR_VERSION + 1 ))
84+
export FAKE_NEXT_MINOR_VERSION=0
85+
else
86+
export FAKE_NEXT_MAJOR_VERSION="${MAJOR_VERSION}"
87+
export FAKE_NEXT_MINOR_VERSION=$(( "${MINOR_VERSION}" + 1 ))
88+
fi
8089

8190
# For a main branch, the current release repository usually comes from
8291
# the OpenShift mirror site, either 'ocp-dev-preview' in the beginning of the
8392
# development cycle or 'ocp' when release candidates are built regularly.
8493
#
8594
# For a release branch, the current release repository should come from the
8695
# official 'rhocp' stream.
87-
CURRENT_RELEASE_REPO="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/microshift/ocp-dev-preview/latest-4.22/el9/os"
88-
CURRENT_RELEASE_VERSION="$(get_vrel_from_beta "${CURRENT_RELEASE_REPO}")"
96+
CURRENT_RELEASE_REPO=""
97+
CURRENT_RELEASE_VERSION=""
8998
export CURRENT_RELEASE_REPO
9099
export CURRENT_RELEASE_VERSION
91100

@@ -100,15 +109,15 @@ export CURRENT_RELEASE_VERSION
100109
# For a release branch, the previous release repository should come from the
101110
# official 'rhocp' stream.# The previous release repository value should either
102111
# point to the OpenShift mirror URL or the 'rhocp' repository name.
103-
PREVIOUS_RELEASE_REPO="rhocp-4.21-for-rhel-9-${UNAME_M}-rpms"
104-
PREVIOUS_RELEASE_VERSION="$(get_vrel_from_rhsm "${PREVIOUS_RELEASE_REPO}")"
112+
PREVIOUS_RELEASE_REPO="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/microshift/ocp-dev-preview/latest-4.22/el9/os"
113+
PREVIOUS_RELEASE_VERSION="$(get_vrel_from_beta "${PREVIOUS_RELEASE_REPO}")"
105114
export PREVIOUS_RELEASE_REPO
106115
export PREVIOUS_RELEASE_VERSION
107116

108117
# The y-2 release repository value should either point to the OpenShift
109118
# mirror URL or the 'rhocp' repository name. It should always come from
110119
# the 'rhocp' stream.
111-
YMINUS2_RELEASE_REPO="rhocp-4.20-for-rhel-9-${UNAME_M}-rpms"
120+
YMINUS2_RELEASE_REPO="rhocp-4.21-for-rhel-9-${UNAME_M}-rpms"
112121
YMINUS2_RELEASE_VERSION="$(get_vrel_from_rhsm "${YMINUS2_RELEASE_REPO}")"
113122
export YMINUS2_RELEASE_REPO
114123
export YMINUS2_RELEASE_VERSION
@@ -129,19 +138,19 @@ export RHOCP_MINOR_Y_BETA
129138
# The 'rhocp_major_y1' and 'rhocp_minor_y1' variables should be the previous major
130139
# and minor version numbers, if the previous release is available through the
131140
# 'rhocp' stream, otherwise empty.
132-
RHOCP_MAJOR_Y1=4
133-
RHOCP_MINOR_Y1=21
141+
RHOCP_MAJOR_Y1=""
142+
RHOCP_MINOR_Y1=""
134143
# The beta repository, containing dependencies, should point to the
135144
# OpenShift mirror URL. The mirror for previous release should always
136145
# be available.
137-
RHOCP_MINOR_Y1_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.21-el9-beta"
146+
RHOCP_MINOR_Y1_BETA="https://mirror.openshift.com/pub/openshift-v4/${UNAME_M}/dependencies/rpms/4.22-el9-beta"
138147
export RHOCP_MAJOR_Y1
139148
export RHOCP_MINOR_Y1
140149
export RHOCP_MINOR_Y1_BETA
141150

142151
# The 'rhocp_major_y2' and 'rhocp_minor_y2' should always be the y-2 version numbers.
143152
export RHOCP_MAJOR_Y2=4
144-
export RHOCP_MINOR_Y2=20
153+
export RHOCP_MINOR_Y2=21
145154

146155
export CNCF_SONOBUOY_VERSION=v0.57.3
147156

test/bin/pyutils/build_bootc_images.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def get_rhocp_beta_url_if_available(major, minor):
124124
def set_rpm_version_info_vars():
125125
# See the test/bin/common_versions.sh script for a full list
126126
# of the variables used for templating
127+
global FAKE_NEXT_MAJOR_VERSION
127128
global FAKE_NEXT_MINOR_VERSION
128129
global PREVIOUS_RELEASE_REPO
129130
global PREVIOUS_RELEASE_VERSION
@@ -136,6 +137,7 @@ def set_rpm_version_info_vars():
136137
global BREW_EC_RELEASE_VERSION
137138
global BREW_NIGHTLY_RELEASE_VERSION
138139

140+
FAKE_NEXT_MAJOR_VERSION = common.get_env_var('FAKE_NEXT_MAJOR_VERSION')
139141
FAKE_NEXT_MINOR_VERSION = common.get_env_var('FAKE_NEXT_MINOR_VERSION')
140142
PREVIOUS_RELEASE_REPO = common.get_env_var('PREVIOUS_RELEASE_REPO')
141143
PREVIOUS_RELEASE_VERSION = common.get_env_var('PREVIOUS_RELEASE_VERSION')
@@ -655,7 +657,7 @@ def main():
655657
else:
656658
extract_container_images(SOURCE_VERSION, LOCAL_REPO, CONTAINER_LIST, args.dry_run)
657659
# The following images are specific to layers that use fake rpms built from source
658-
extract_container_images(f"4.{FAKE_NEXT_MINOR_VERSION}.*", NEXT_REPO, CONTAINER_LIST, args.dry_run)
660+
extract_container_images(f"{FAKE_NEXT_MAJOR_VERSION}.{FAKE_NEXT_MINOR_VERSION}.*", NEXT_REPO, CONTAINER_LIST, args.dry_run)
659661
extract_container_images(PREVIOUS_RELEASE_VERSION, PREVIOUS_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
660662
extract_container_images(YMINUS2_RELEASE_VERSION, YMINUS2_RELEASE_REPO, CONTAINER_LIST, args.dry_run)
661663
# The following images are specific to the brew release versions

test/bin/pyutils/generate_common_versions.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,12 +349,16 @@ def generate_common_versions(major_version, minor_version):
349349
# creating PRs that clear the version due to transient failures.
350350
logging.info("Getting GITOPS_VERSION")
351351
gitops_version = get_gitops_version(major_version, minor_version)
352-
if gitops_version is None:
352+
if not gitops_version:
353353
target_file = pathlib.Path(__file__).resolve().parent / '../common_versions.sh'
354354
args = ['grep', '-oP', '(?<=GITOPS_VERSION=).*', str(target_file)]
355355
gitops_version = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True, check=True).stdout.strip()
356356
logging.info(f"API fetch failed, preserving existing GITOPS_VERSION={gitops_version}")
357357

358+
last_minor_for_major_bash = " ".join(
359+
f"[{major}]={info['last_minor']}" for major, info in VERSION_MAP.items()
360+
)
361+
358362
template_path = pathlib.Path(__file__).resolve().parent / '../../assets/common_versions.sh.template'
359363

360364
with open(template_path, 'r') as f:
@@ -384,7 +388,8 @@ def generate_common_versions(major_version, minor_version):
384388
CNCF_SONOBUOY_VERSION=CNCF_SONOBUOY_VERSION,
385389
CNCF_SYSTEMD_LOGS_VERSION=CNCF_SYSTEMD_LOGS_VERSION,
386390
GITOPS_VERSION=gitops_version,
387-
ARCH=ARCH
391+
ARCH=ARCH,
392+
last_minor_for_major_bash=last_minor_for_major_bash
388393
)
389394

390395
output_noarch = output.replace(ARCH, '${UNAME_M}')

test/image-blueprints-bootc/el10/layer2-presubmit/group2/rhel102-bootc-source-fake-next-minor.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ COPY ./bootc-images/$USHIFT_RPM_REPO_NAME.repo ./bootc-images/microshift-fast-da
1414
# Print repository configuration contents.
1515
# Install MicroShift, test agent and cleanup.
1616
RUN dnf repoinfo --enabled && \
17-
dnf install -y "microshift-4.{{ env.Getenv "FAKE_NEXT_MINOR_VERSION" }}.*" && \
17+
dnf install -y "microshift-{{ env.Getenv "FAKE_NEXT_MAJOR_VERSION" }}.{{ env.Getenv "FAKE_NEXT_MINOR_VERSION" }}.*" && \
1818
rm -vf /etc/yum.repos.d/microshift-*.repo && \
1919
rm -rvf $USHIFT_RPM_REPO_PATH && \
2020
dnf clean all

test/image-blueprints-bootc/el9/layer2-presubmit/group2/rhel98-bootc-source-fake-next-minor.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ COPY ./bootc-images/$USHIFT_RPM_REPO_NAME.repo ./bootc-images/microshift-fast-da
1414
# Print repository configuration contents.
1515
# Install MicroShift, test agent and cleanup.
1616
RUN dnf repoinfo --enabled && \
17-
dnf install -y "microshift-4.{{ env.Getenv "FAKE_NEXT_MINOR_VERSION" }}.*" && \
17+
dnf install -y "microshift-{{ env.Getenv "FAKE_NEXT_MAJOR_VERSION" }}.{{ env.Getenv "FAKE_NEXT_MINOR_VERSION" }}.*" && \
1818
rm -vf /etc/yum.repos.d/microshift-*.repo && \
1919
rm -rvf $USHIFT_RPM_REPO_PATH && \
2020
dnf clean all

test/image-blueprints/layer2-presubmit/group1/rhel98-source-fake-next-minor.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ distro = "rhel-98"
1717

1818
[[packages]]
1919
name = "microshift"
20-
version = "4.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
20+
version = "{{ .Env.FAKE_NEXT_MAJOR_VERSION }}.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
2121

2222
[[packages]]
2323
name = "microshift-greenboot"
24-
version = "4.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
24+
version = "{{ .Env.FAKE_NEXT_MAJOR_VERSION }}.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
2525

2626
[[packages]]
2727
name = "microshift-networking"
28-
version = "4.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
28+
version = "{{ .Env.FAKE_NEXT_MAJOR_VERSION }}.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
2929

3030
[[packages]]
3131
name = "microshift-selinux"
32-
version = "4.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
32+
version = "{{ .Env.FAKE_NEXT_MAJOR_VERSION }}.{{ .Env.FAKE_NEXT_MINOR_VERSION }}.*"
3333

3434
[[packages]]
3535
name = "microshift-test-agent"

0 commit comments

Comments
 (0)