Skip to content

OCPERT-349: Add job command for running Stage testing prow job#969

Open
tomasdavidorg wants to merge 2 commits intoopenshift:mainfrom
tomasdavidorg:OCPERT-349
Open

OCPERT-349: Add job command for running Stage testing prow job#969
tomasdavidorg wants to merge 2 commits intoopenshift:mainfrom
tomasdavidorg:OCPERT-349

Conversation

@tomasdavidorg
Copy link
Copy Markdown
Contributor

@tomasdavidorg tomasdavidorg requested a review from rioliu-rh March 26, 2026 12:04
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Mar 26, 2026
@openshift-ci-robot
Copy link
Copy Markdown

openshift-ci-robot commented Mar 26, 2026

@tomasdavidorg: This pull request references OCPERT-349 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 story to target the "4.22.0" version, but no target version was set.

Details

In response to this:

https://redhat.atlassian.net/browse/OCPERT-349

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 Mar 26, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03600d74-448c-4b78-ba82-6d47c4272578

📥 Commits

Reviewing files that changed from the base of the PR and between 17b5577 and 9feda89.

📒 Files selected for processing (1)
  • prow/job/job.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • prow/job/job.py

Walkthrough

Adds documentation for two new CLI commands and implements stage-testing job support: payload URL validation, minor-release extraction, Gangway job submission, response handling, and result polling; also exposes a new CLI command.

Changes

Cohort / File(s) Summary
Documentation
prow/README.md
Updated CLI command list spacing; added run_stage_testing and run_image_consistency_check command docs, invocation examples, payload (-p) usage, and sample output including job IDs/URLs.
Stage-testing Implementation
prow/job/job.py
Added STAGE_TESTING_JOB_NAME_TEMPLATE constant, _get_minor_release_from_payload_url() helper, and run_stage_testing(payload_url) to validate payload URL, construct job name, submit Gangway job with RELEASE_IMAGE_LATEST, handle non-200 responses, extract job id, poll via get_job_results(..., poll=True), and added corresponding CLI command. Minor whitespace cleanups.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ 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 LuboTerifaj and barboras7 March 26, 2026 12:04
@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 26, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tomasdavidorg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

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: 2

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

Inline comments:
In `@prow/job/job.py`:
- Around line 440-444: The Gangway POST call at job_run_res =
self._get_session().post(...) has no timeout and can hang; add a timeout kwarg
to the post call (for example timeout=self.request_timeout or timeout=10) so the
request will fail fast on network stalls, and if you choose a configurable value
add a request_timeout attribute (or a constant) to the class and use that in the
call; update the post invocation in job_run_res to include
timeout=<configured_value>.

In `@prow/README.md`:
- Around line 93-97: The README wording "shipment MR" is inconsistent with the
CLI option; update the README example and description for the
run_image_consistency_check command to refer to the merge request ID and the
actual flag name used by the CLI (--mr-id / -m), e.g., change "shipment MR" to
"merge request ID (MR) via -m/--mr-id" and ensure the sample invocation and
explanatory text match the option implemented in the job
run_image_consistency_check command and the CLI option --mr-id in
prow/job/job.py.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 71d18871-07d9-4be6-929c-f57cd920fc02

📥 Commits

Reviewing files that changed from the base of the PR and between 40da513 and 17b5577.

📒 Files selected for processing (2)
  • prow/README.md
  • prow/job/job.py

Comment on lines +440 to +444
job_run_res = self._get_session().post(
url=url,
json=data,
headers=self.get_prow_headers()
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
python - <<'PY'
import re
from pathlib import Path

p = Path("prow/job/job.py")
text = p.read_text(encoding="utf-8")
m = re.search(r"def run_stage_testing\(.*?return job_status", text, re.S)
if not m:
    raise SystemExit("run_stage_testing block not found")
block = m.group(0)
print("timeout_present_in_run_stage_testing_post =", "timeout=" in block)
for i, line in enumerate(block.splitlines(), 1):
    if ".post(" in line or "timeout=" in line:
        print(f"{i:03d}: {line}")
PY

Repository: openshift/release-tests

Length of output: 169


🏁 Script executed:

#!/bin/bash
# Verify lines 440-444 match the review comment
head -444 prow/job/job.py | tail -20

Repository: openshift/release-tests

Length of output: 695


🏁 Script executed:

#!/bin/bash
# Search for all .post() calls in the file to check for other timeout issues
rg "\.post\(" prow/job/job.py -A 3 -B 2

Repository: openshift/release-tests

Length of output: 650


🏁 Script executed:

#!/bin/bash
# Check for any session configuration or timeout defaults in the file
rg "session|timeout" prow/job/job.py -i | head -20

Repository: openshift/release-tests

Length of output: 1183


Add a timeout to the Gangway POST request.

The POST call to the Gangway API (lines 440-444) currently has no timeout, so the CLI can block indefinitely on network/API stalls.

        job_run_res = self._get_session().post(
            url=url,
            json=data,
-           headers=self.get_prow_headers()
+           headers=self.get_prow_headers(),
+           timeout=30
        )
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
job_run_res = self._get_session().post(
url=url,
json=data,
headers=self.get_prow_headers()
)
job_run_res = self._get_session().post(
url=url,
json=data,
headers=self.get_prow_headers(),
timeout=30
)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@prow/job/job.py` around lines 440 - 444, The Gangway POST call at job_run_res
= self._get_session().post(...) has no timeout and can hang; add a timeout kwarg
to the post call (for example timeout=self.request_timeout or timeout=10) so the
request will fail fast on network stalls, and if you choose a configurable value
add a request_timeout attribute (or a constant) to the class and use that in the
call; update the post invocation in job_run_res to include
timeout=<configured_value>.

Comment on lines +93 to +97
Run the image consistency check Prow job for a given release payload and shipment MR.

```console
$ job run_image_consistency_check -p quay.io/openshift-release-dev/ocp-release:4.19.1-x86_64 -m 189
Image consistency check job id: a1b2c3d4-e5f6-7890-abcd-ef1234567890
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Align MR argument wording with the implemented CLI option.

Line 93 says “shipment MR”, but the command interface uses merge request ID via -m/--mr-id (prow/job/job.py, Line 816). Please align wording/flag naming in README to prevent confusion.

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

In `@prow/README.md` around lines 93 - 97, The README wording "shipment MR" is
inconsistent with the CLI option; update the README example and description for
the run_image_consistency_check command to refer to the merge request ID and the
actual flag name used by the CLI (--mr-id / -m), e.g., change "shipment MR" to
"merge request ID (MR) via -m/--mr-id" and ensure the sample invocation and
explanatory text match the option implemented in the job
run_image_consistency_check command and the CLI option --mr-id in
prow/job/job.py.

@@ -350,7 +351,11 @@ def _is_valid_payload_url(self, payload_url: str) -> bool:
pattern = r"^quay\.io/openshift-release-dev/ocp-release:\d+\.\d+\.\d+.*-x86_64$"
return re.match(pattern, payload_url) is not None

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Remove trailing whitespace on this line for consistency with project style.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

def _get_minor_release_from_payload_url(self, payload_url):
"""Extract minor release (e.g. '4.19') from a validated payload URL."""
z_version = payload_url.split(":")[1].split("-")[0]
return ".".join(z_version.split(".")[:2])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since you've extracted the minor release parsing logic into _get_minor_release_from_payload_url(), consider refactoring run_image_consistency_check() to use this same helper method instead of duplicating the logic.

This would eliminate duplication and make the code more maintainable. For example, you could replace the inline parsing in run_image_consistency_check() with a call to this helper.

Copy link
Copy Markdown
Contributor Author

@tomasdavidorg tomasdavidorg Mar 30, 2026

Choose a reason for hiding this comment

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

There is no duplicated parsing in run_image_consistency_check(). It uses a single constant job name (IMAGE_CONSISTENCY_CHECK_JOB_NAME) and passes the payload URL as MULTISTAGE_PARAM_OVERRIDE_PAYLOAD_URL without needing to extract the minor release from it.

Or do you mean something else?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

all right


minor_release = self._get_minor_release_from_payload_url(payload_url)

job_name = Jobs.STAGE_TESTING_JOB_NAME_TEMPLATE.format(minor_release=minor_release)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The job name is already printed on line 427, which is good for consistency with run_image_consistency_check(). Nice work maintaining the same output pattern!

@tomasdavidorg
Copy link
Copy Markdown
Contributor Author

/retest

@openshift-ci
Copy link
Copy Markdown

openshift-ci bot commented Mar 30, 2026

@tomasdavidorg: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants