Skip to content

NO-ISSUE: Fix get_latest_rhocp_repo to support crossing major versions#6519

Merged
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
pacevedom:configure-vm-5.0
Apr 17, 2026
Merged

NO-ISSUE: Fix get_latest_rhocp_repo to support crossing major versions#6519
openshift-merge-bot[bot] merged 2 commits intoopenshift:mainfrom
pacevedom:configure-vm-5.0

Conversation

@pacevedom
Copy link
Copy Markdown
Contributor

@pacevedom pacevedom commented Apr 17, 2026

Summary by CodeRabbit

  • Improvements
    • Enhanced repository discovery with stronger cross-major fallback to find previous major/minor releases.
    • Optimized version search with bounded iteration and early termination for faster resolution.
    • Aligned version parsing and repository URL construction for more accurate mirror selection.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Apr 17, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@pacevedom: This pull request explicitly references no jira issue.

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 17, 2026

Walkthrough

The PR refactors repository-version discovery in scripts/get-latest-rhocp-repo.sh to a bounded iterative loop with cross-major fallback via get_prev_version() and a LAST_MINOR_FOR_MAJOR map. It also updates RHEL-beta URL parsing and previous-version invocation in scripts/devenv-builder/configure-vm.sh to use the new major/minor parsing.

Changes

Cohort / File(s) Summary
Version discovery & loop logic
scripts/get-latest-rhocp-repo.sh
Replaced descending seq minor loop with a bounded for (( step... )) loop and max_steps. Added get_prev_version() helper and LAST_MINOR_FOR_MAJOR associative array. Adjusted repo/beta-mirror URL construction to use check_major/check_minor and added early loop termination when no prior version exists. Output format now includes check_major in beta lines.
RHEL-beta parsing alignment
scripts/devenv-builder/configure-vm.sh
Changed RHOCP URL parsing to extract major and ver (fields 2 and 3) and updated OCP_REPO_NAME and repo display name to use ${major}.${ver}. Switched get_prev_version call to pass ("${major}" "${ver}") to match the new parsing.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly summarizes the main change: adding support for crossing major versions in the get_latest_rhocp_repo function, which aligns with the primary code modifications shown in the changeset.
Stable And Deterministic Test Names ✅ Passed PR modifies only shell scripts; custom check applies exclusively to Ginkgo test names in Go test files, which are not modified.
Test Structure And Quality ✅ Passed The custom check is not applicable to this pull request. The PR only modifies bash shell scripts for RHOCP version handling. The test quality check is designed for Ginkgo test code, which is not present in the modified files.
Microshift Test Compatibility ✅ Passed PR modifies only shell utility scripts; no new Ginkgo e2e tests added. Custom check targets new Ginkgo e2e test files and is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR modifies only shell scripts for RHOCP repository configuration and VM setup. No new Ginkgo e2e tests are added, making SNO Test Compatibility check not applicable.
Topology-Aware Scheduling Compatibility ✅ Passed Pull request modifies only shell utility scripts for RHOCP repository queries and VM configuration, with no Kubernetes deployment manifests, operators, controllers, or scheduling constraints.
Ote Binary Stdout Contract ✅ Passed PR modifies only bash shell utility scripts for repository and VM configuration. No Go files or OTE binaries modified.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR modifies only shell utility scripts for repository version management and VM configuration. No Ginkgo e2e test files are added or modified.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from copejon and pmtk April 17, 2026 07:22
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 17, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/get-latest-rhocp-repo.sh (1)

60-75: max_steps=1 when args are provided makes the fallback logic unreachable for those callers.

With explicit major/minor args, get_prev_version at lines 95-100 is computed but never consumed (loop exits after one iteration). Harmless, just dead work — you could early-return after the two repo probes in that branch, or accept it as-is for simplicity.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/get-latest-rhocp-repo.sh` around lines 60 - 75, The branch that sets
current_minor/current_major when arguments are provided still sets max_steps=1
causing the loop that uses get_prev_version to exit after one iteration so its
computation is dead work; fix by either returning early from the "both minor and
major provided" and "only minor provided" branches after the two repo probes (so
get_prev_version is never invoked for callers that passed args) or change
max_steps in those branches to the intended value (e.g., the same default as the
no-args branch) so the fallback loop can run; update the logic around
current_minor, current_major, max_steps and the call sites that rely on
get_prev_version to ensure either an early return or correct max_steps is used.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/get-latest-rhocp-repo.sh`:
- Around line 26-27: The hardcoded associative array LAST_MINOR_FOR_MAJOR
(declare -A LAST_MINOR_FOR_MAJOR=([4]=22)) can go stale; update the script to
either derive the last minor dynamically or add a clear TODO comment for
maintainers to update it when a new 4.x minor ships. Locate the
LAST_MINOR_FOR_MAJOR declaration in scripts/get-latest-rhocp-repo.sh and replace
or augment it: preferably implement logic to compute the highest 4.z available
(e.g., by listing repo tags/releases and parsing the max minor) or, if not
feasible, add a brief comment next to LAST_MINOR_FOR_MAJOR noting it must be
bumped when 4.x publishes a newer minor and include the date/owner for
accountability.

---

Nitpick comments:
In `@scripts/get-latest-rhocp-repo.sh`:
- Around line 60-75: The branch that sets current_minor/current_major when
arguments are provided still sets max_steps=1 causing the loop that uses
get_prev_version to exit after one iteration so its computation is dead work;
fix by either returning early from the "both minor and major provided" and "only
minor provided" branches after the two repo probes (so get_prev_version is never
invoked for callers that passed args) or change max_steps in those branches to
the intended value (e.g., the same default as the no-args branch) so the
fallback loop can run; update the logic around current_minor, current_major,
max_steps and the call sites that rely on get_prev_version to ensure either an
early return or correct max_steps is used.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 9b683f1a-e75f-4550-95e4-c986fd1920ae

📥 Commits

Reviewing files that changed from the base of the PR and between 6796171 and 42a8239.

📒 Files selected for processing (1)
  • scripts/get-latest-rhocp-repo.sh

Comment thread scripts/get-latest-rhocp-repo.sh
@pacevedom
Copy link
Copy Markdown
Contributor Author

/test ?

@pacevedom
Copy link
Copy Markdown
Contributor Author

/test ocp-full-conformance-rhel-eus

@pmtk
Copy link
Copy Markdown
Member

pmtk commented Apr 17, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2026
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2026
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
scripts/devenv-builder/configure-vm.sh (1)

217-218: ⚠️ Potential issue | 🔴 Critical

Line 218 numeric branch has asymmetric output handling—only receives minor, not major.

get-latest-rhocp-repo.sh outputs only ${check_minor} on line 85 (numeric path) but ${rhocp_beta_url},${check_major},${check_minor} on line 91 (beta path). When the helper crosses major boundaries and finds a hit in the numeric path, configure-vm.sh applies a minor from a different major to the hardcoded ocp_major from Makefile. The beta branch avoids this by parsing both; align the numeric path to also include and parse the major (e.g., change line 85 to echo "${check_major},${check_minor}" and update the parser in configure-vm.sh accordingly).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/devenv-builder/configure-vm.sh` around lines 217 - 218, The numeric
path of the helper only returns the minor, causing configure-vm.sh to combine a
parsed minor with the hardcoded ocp_major; update get-latest-rhocp-repo.sh
numeric branch to output both check_major and check_minor (e.g., echo
"${check_major},${check_minor}") and then modify configure-vm.sh where it reads
RHOCP/parsed values so it splits the helper output into parsed_major and
parsed_minor and uses parsed_major instead of the hardcoded ocp_major when
constructing the repo string in the subscription-manager repos --enable
"rhocp-${parsed_major}.${parsed_minor}-for-rhel-9-$(uname -m)-rpms" branch (keep
the existing beta parsing behavior for the other branch).
🧹 Nitpick comments (1)
scripts/devenv-builder/configure-vm.sh (1)

199-214: Nit: duplicated get_prev_version/LAST_MINOR_FOR_MAJOR with get-latest-rhocp-repo.sh.

Same logic now lives in two scripts. Since configure-vm.sh already sources ${RHOCP_REPO} via execution, consider exposing the helper from that script (or a small shared lib) to keep the cross-major map in one place. Not blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/devenv-builder/configure-vm.sh` around lines 199 - 214, Duplicate
get_prev_version and last_minor_for_major logic should be centralized; remove
the copy from configure-vm.sh and consume the canonical implementation from
get-latest-rhocp-repo.sh (or a new small shared lib). Export or move the map
(last_minor_for_major / LAST_MINOR_FOR_MAJOR) and the function get_prev_version
into the repo script (or shared lib) and ensure configure-vm.sh sources
RHOCP_REPO (or the shared lib) and calls get_prev_version rather than defining
its own copy; update any references to prev_major/prev_minor to use the
centralized helper names so there are no conflicting local definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@scripts/devenv-builder/configure-vm.sh`:
- Around line 217-218: The numeric path of the helper only returns the minor,
causing configure-vm.sh to combine a parsed minor with the hardcoded ocp_major;
update get-latest-rhocp-repo.sh numeric branch to output both check_major and
check_minor (e.g., echo "${check_major},${check_minor}") and then modify
configure-vm.sh where it reads RHOCP/parsed values so it splits the helper
output into parsed_major and parsed_minor and uses parsed_major instead of the
hardcoded ocp_major when constructing the repo string in the
subscription-manager repos --enable
"rhocp-${parsed_major}.${parsed_minor}-for-rhel-9-$(uname -m)-rpms" branch (keep
the existing beta parsing behavior for the other branch).

---

Nitpick comments:
In `@scripts/devenv-builder/configure-vm.sh`:
- Around line 199-214: Duplicate get_prev_version and last_minor_for_major logic
should be centralized; remove the copy from configure-vm.sh and consume the
canonical implementation from get-latest-rhocp-repo.sh (or a new small shared
lib). Export or move the map (last_minor_for_major / LAST_MINOR_FOR_MAJOR) and
the function get_prev_version into the repo script (or shared lib) and ensure
configure-vm.sh sources RHOCP_REPO (or the shared lib) and calls
get_prev_version rather than defining its own copy; update any references to
prev_major/prev_minor to use the centralized helper names so there are no
conflicting local definitions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 799812aa-8eb0-4f33-8a1b-3e542ad80ba7

📥 Commits

Reviewing files that changed from the base of the PR and between 42a8239 and 48fab8c.

📒 Files selected for processing (2)
  • scripts/devenv-builder/configure-vm.sh
  • scripts/get-latest-rhocp-repo.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/get-latest-rhocp-repo.sh

@pmtk
Copy link
Copy Markdown
Member

pmtk commented Apr 17, 2026

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Apr 17, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented Apr 17, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pacevedom, pmtk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@pacevedom
Copy link
Copy Markdown
Contributor Author

/verified by CI

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Apr 17, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@pacevedom: This PR has been marked as verified by CI.

Details

In response to this:

/verified by CI

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-merge-bot openshift-merge-bot Bot merged commit bbad4d6 into openshift:main Apr 17, 2026
13 checks passed
@pacevedom pacevedom deleted the configure-vm-5.0 branch April 17, 2026 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. verified Signifies that the PR passed pre-merge verification criteria

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants