Skip to content

USHIFT-6786: Preserve GITOPS_VERSION when access.redhat.com API fetch fails#6476

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
agullon:USHIFT-6769
Apr 8, 2026
Merged

USHIFT-6786: Preserve GITOPS_VERSION when access.redhat.com API fetch fails#6476
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
agullon:USHIFT-6769

Conversation

@agullon
Copy link
Copy Markdown
Contributor

@agullon agullon commented Apr 8, 2026

Summary

  • When access.redhat.com is unreachable, get_gitops_version() returned "", clearing GITOPS_VERSION in common_versions.sh and creating spurious PRs (e.g. [release-4.22] NO-ISSUE: Update common_versions.sh #6475)
  • Return None on API failure to distinguish from "no compatible version found" ("")
  • Fall back to the existing GITOPS_VERSION value so the file stays unchanged and no PR is created

Jira

USHIFT-6786

@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 8, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 8, 2026

@agullon: This pull request references USHIFT-6786 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • When access.redhat.com is unreachable, get_gitops_version() returned "", clearing GITOPS_VERSION in common_versions.sh and creating spurious PRs (e.g. [release-4.22] NO-ISSUE: Update common_versions.sh #6475)
  • Return None on API failure to distinguish from "no compatible version found" ("")
  • Fall back to the existing GITOPS_VERSION value so the file stays unchanged and no PR is created

Jira

USHIFT-6786

Test plan

  • Simulate access.redhat.com failure (e.g. firewall block) and run generate_common_versions.py — verify GITOPS_VERSION is preserved from existing file
  • Run with working API — verify normal behavior unchanged

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 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: cea3b12d-2b6e-4b00-a09e-b5c741d12e0d

📥 Commits

Reviewing files that changed from the base of the PR and between 2be60d0 and 2d538ff.

📒 Files selected for processing (1)
  • test/bin/pyutils/generate_common_versions.py

Walkthrough

get_gitops_version(minor_version) now initializes and accumulates versions, narrows retry/error handling to requests.RequestException, ValueError, and AttributeError, and returns None after three failed attempts. generate_common_versions(minor_version) treats None as an API failure, greps the existing GITOPS_VERSION from test/bin/common_versions.sh (via ../common_versions.sh), assigns that value, and logs preservation of the existing version.

Changes

Cohort / File(s) Summary
GitOps version generation
test/bin/pyutils/generate_common_versions.py, test/bin/common_versions.sh
Refined error handling and control flow: get_gitops_version() initializes versions, parses JSON from successful responses into versions, narrows caught exceptions to requests.RequestException, ValueError, and AttributeError, and returns None immediately after three failed attempts. Removed the old post-loop resp.json() usage and empty-string sentinel. generate_common_versions() treats None as API fetch failure, falls back by grepping the current GITOPS_VERSION from ../common_versions.sh, assigns that preserved value to gitops_version, and logs the preservation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

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

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

@openshift-ci openshift-ci bot requested review from pmtk and vanhalenar April 8, 2026 10:32
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 8, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Apr 8, 2026

@agullon: This pull request references USHIFT-6786 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the bug to target the "4.22.0" version, but no target version was set.

Details

In response to this:

Summary

  • When access.redhat.com is unreachable, get_gitops_version() returned "", clearing GITOPS_VERSION in common_versions.sh and creating spurious PRs (e.g. [release-4.22] NO-ISSUE: Update common_versions.sh #6475)
  • Return None on API failure to distinguish from "no compatible version found" ("")
  • Fall back to the existing GITOPS_VERSION value so the file stays unchanged and no PR is created

Jira

USHIFT-6786

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.

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)
test/bin/pyutils/generate_common_versions.py (1)

217-230: ⚠️ Potential issue | 🟠 Major

Handle HTTP errors in retry loop to enable fallback.

When requests.get() succeeds but raise_for_status() throws (4xx/5xx responses), the response object is already assigned to resp. After 3 failed attempts, resp is non-None, so the check on line 228 never triggers and the fallback on lines 296-300 never runs. The GITOPS_VERSION preservation fails.

Fix: Return from exception handler on final attempt
-    resp = None
     for attempt in range(1, 4):
         try:
             resp = requests.get(url, params=params, timeout=10)
             resp.raise_for_status()
             break
-        except Exception as e:
-            logging.warning(f"Attempt {attempt} failed with error: {e}. Retrying...")
-            time.sleep(2)
-            continue
-
-    if resp is None:
-        logging.error(f"Failed to fetch data from {url} after 3 attempts")
-        return None
+        except requests.RequestException as e:
+            if attempt == 3:
+                logging.error(f"Failed to fetch data from {url} after 3 attempts: {e}")
+                return None
+            logging.warning(f"Attempt {attempt} failed with error: {e}. Retrying...")
+            time.sleep(2)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/bin/pyutils/generate_common_versions.py` around lines 217 - 230, The
retry loop assigns resp before calling resp.raise_for_status(), so when
raise_for_status() raises on the final attempt resp remains non-None and the
later "if resp is None" check is skipped; update the except block inside the
for-loop that wraps requests.get/resp.raise_for_status() to detect the final
attempt (when attempt == 3) and immediately log the error and return None (or
otherwise exit) so the fallback logic that preserves GITOPS_VERSION can run;
refer to the existing variables and calls resp, requests.get(..., timeout=10),
resp.raise_for_status(), and the attempt loop to locate where to add the early
return.
🤖 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 `@test/bin/pyutils/generate_common_versions.py`:
- Around line 217-230: The retry loop assigns resp before calling
resp.raise_for_status(), so when raise_for_status() raises on the final attempt
resp remains non-None and the later "if resp is None" check is skipped; update
the except block inside the for-loop that wraps
requests.get/resp.raise_for_status() to detect the final attempt (when attempt
== 3) and immediately log the error and return None (or otherwise exit) so the
fallback logic that preserves GITOPS_VERSION can run; refer to the existing
variables and calls resp, requests.get(..., timeout=10),
resp.raise_for_status(), and the attempt loop to locate where to add the early
return.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 4818d6bb-b573-4003-b58a-dcb197872e6a

📥 Commits

Reviewing files that changed from the base of the PR and between 0f9381f and 4cbc595.

📒 Files selected for processing (1)
  • test/bin/pyutils/generate_common_versions.py

@agullon
Copy link
Copy Markdown
Contributor Author

agullon commented Apr 8, 2026

/verified by @agullon

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

@agullon: This PR has been marked as verified by @agullon.

Details

In response to this:

/verified by @agullon

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-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Apr 8, 2026
@agullon
Copy link
Copy Markdown
Contributor Author

agullon commented Apr 8, 2026

/verified by @agullon

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

@agullon: This PR has been marked as verified by @agullon.

Details

In response to this:

/verified by @agullon

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.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/bin/pyutils/generate_common_versions.py`:
- Around line 217-230: The code currently calls resp.json() and indexes data
outside the retry try/except so malformed JSON or unexpected payloads raise and
bypass retries; move the resp.json() call and basic payload validation into the
existing try block (the loop around requests.get) and catch json.JSONDecodeError
and TypeError/KeyError (or validate that data is a dict with "data" -> list ->
[0] -> "versions") to trigger a retry on parse/shape failures; ensure the
final-attempt branch that logs the failure (using the same message that mentions
url and attempt count) returns None or falls back to the
preserve-existing-version path, and update references to resp, data,
current_microshift_minor_version, and gitops_version_from_api_docs accordingly
so downstream loops only run when data is valid.
🪄 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), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f27cf37a-954e-41c9-89de-496ff07c9ae3

📥 Commits

Reviewing files that changed from the base of the PR and between 4cbc595 and 2be60d0.

📒 Files selected for processing (1)
  • test/bin/pyutils/generate_common_versions.py

When access.redhat.com is unreachable, get_gitops_version() was
returning an empty string, causing common_versions.sh to clear
GITOPS_VERSION and triggering a spurious PR (e.g. openshift#6475).

Return None on API failure to distinguish it from "no compatible
version found", and fall back to the existing value in
common_versions.sh so the file stays unchanged and no PR is created.

pre-commit.check-secrets: ENABLED
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Apr 8, 2026
@pmtk
Copy link
Copy Markdown
Member

pmtk commented Apr 8, 2026

/lgtm

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

openshift-ci bot commented Apr 8, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: agullon, 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

@agullon
Copy link
Copy Markdown
Contributor Author

agullon commented Apr 8, 2026

/verified by @agullon

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

@agullon: This PR has been marked as verified by @agullon.

Details

In response to this:

/verified by @agullon

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.

@agullon
Copy link
Copy Markdown
Contributor Author

agullon commented Apr 8, 2026

/retest

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 0b83947 and 2 for PR HEAD 2d538ff in total

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci bot commented Apr 8, 2026

@agullon: all tests passed!

Full PR test history. Your PR dashboard.

Details

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

@openshift-merge-bot openshift-merge-bot bot merged commit d9ab91d into openshift:main Apr 8, 2026
19 checks passed
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