-
Notifications
You must be signed in to change notification settings - Fork 41
OCPERT-349: Add job command for running Stage testing prow job #969
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -26,6 +26,7 @@ class Jobs: | |||||||||||||||||||||||
| POLL_INTERVAL_SECONDS = 5 | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| IMAGE_CONSISTENCY_CHECK_JOB_NAME = "periodic-ci-openshift-release-tests-main-image-consistency-check" | ||||||||||||||||||||||||
| STAGE_TESTING_JOB_NAME_TEMPLATE = "periodic-ci-openshift-openshift-tests-private-release-{minor_release}-stage-testing-e2e-aws-ipi" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def __init__(self): | ||||||||||||||||||||||||
| self.run = False | ||||||||||||||||||||||||
|
|
@@ -346,11 +347,14 @@ def _is_valid_payload_url(self, payload_url: str) -> bool: | |||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||
| True if the payload URL is valid, False otherwise. | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| pattern = r"^quay\.io/openshift-release-dev/ocp-release:\d+\.\d+\.\d+.*-x86_64$" | ||||||||||||||||||||||||
| return re.match(pattern, payload_url) is not None | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove trailing whitespace on this line for consistency with project style.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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]) | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you've extracted the minor release parsing logic into This would eliminate duplication and make the code more maintainable. For example, you could replace the inline parsing in
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no duplicated parsing in Or do you mean something else?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all right |
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def run_image_consistency_check(self, payload_url: str, mr_id: int) -> dict: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| Run image consistency check Prow job. | ||||||||||||||||||||||||
|
|
@@ -362,7 +366,6 @@ def run_image_consistency_check(self, payload_url: str, mr_id: int) -> dict: | |||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||
| A dictionary containing the job info. | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if not self._is_valid_payload_url(payload_url): | ||||||||||||||||||||||||
| raise Exception(f"Invalid payload URL: {payload_url}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
@@ -399,9 +402,59 @@ def run_image_consistency_check(self, payload_url: str, mr_id: int) -> dict: | |||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return job_status | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def run_stage_testing(self, payload_url: str) -> dict: | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| Run stage testing Prow job. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| The Prow job name is version-specific: | ||||||||||||||||||||||||
| periodic-ci-openshift-openshift-tests-private-release-{minor_release}-stage-testing-e2e-aws-ipi | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||
| payload_url: The URL of the release payload to test | ||||||||||||||||||||||||
| (e.g. quay.io/openshift-release-dev/ocp-release:4.19.1-x86_64) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||||
| A dictionary containing the job info. | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| if not self._is_valid_payload_url(payload_url): | ||||||||||||||||||||||||
| raise Exception(f"Invalid payload URL: {payload_url}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| minor_release = self._get_minor_release_from_payload_url(payload_url) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| job_name = Jobs.STAGE_TESTING_JOB_NAME_TEMPLATE.format(minor_release=minor_release) | ||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||||||||||||||||||||
| print(f"Stage testing job name: {job_name}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| url = self.gangway_url + job_name | ||||||||||||||||||||||||
| data = { | ||||||||||||||||||||||||
| "job_execution_type": "1", | ||||||||||||||||||||||||
| "pod_spec_options": { | ||||||||||||||||||||||||
| "envs": { | ||||||||||||||||||||||||
| "RELEASE_IMAGE_LATEST": payload_url, | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
| } | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| job_run_res = self._get_session().post( | ||||||||||||||||||||||||
| url=url, | ||||||||||||||||||||||||
| json=data, | ||||||||||||||||||||||||
| headers=self.get_prow_headers() | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
Comment on lines
+437
to
+441
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 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}")
PYRepository: 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 -20Repository: 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 2Repository: 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 -20Repository: 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
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||
| if job_run_res.status_code != 200: | ||||||||||||||||||||||||
| raise Exception( | ||||||||||||||||||||||||
| f"Failed to run stage testing job '{job_name}'. " | ||||||||||||||||||||||||
| f"Error code: {job_run_res.status_code}, reason: {job_run_res.reason}" | ||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| job_id = json.loads(job_run_res.text)["id"] | ||||||||||||||||||||||||
| print(f"Stage testing job id: {job_id}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| job_status = self.get_job_results(job_id, poll=True) | ||||||||||||||||||||||||
| print(f"Stage testing job url: {job_status['jobURL']}") | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| return job_status | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| def run_job(self, job_name, payload, upgrade_from, upgrade_to): | ||||||||||||||||||||||||
| """Function run Prow job by calling the API""" | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| job_id = None | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| if job_name is None: | ||||||||||||||||||||||||
|
|
@@ -767,6 +820,18 @@ def run_image_consistency_check(payload_url: str, mr_id: int): | |||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| JOB.run_image_consistency_check(payload_url, mr_id) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| @cli.command("run_stage_testing") | ||||||||||||||||||||||||
| @click.option("-p", "--payload-url", type=str, required=True, help="Payload URL (e.g. quay.io/openshift-release-dev/ocp-release:4.19.1-x86_64)") | ||||||||||||||||||||||||
| def run_stage_testing(payload_url: str): | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| Run stage testing Prow job for a given payload. | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| Args: | ||||||||||||||||||||||||
| payload_url (str): The URL of the payload | ||||||||||||||||||||||||
| """ | ||||||||||||||||||||||||
| JOB.run_stage_testing(payload_url) | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
| # no need this program entry since this file won't be imported as a module. | ||||||||||||||||||||||||
| # if __name__ == "__main__": | ||||||||||||||||||||||||
| # start = time.time() | ||||||||||||||||||||||||
|
|
||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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