Skip to content

ART-21879: Add elliott verify-kernel-tag command - #3250

Open
tomasdavidorg wants to merge 4 commits into
openshift-eng:mainfrom
tomasdavidorg:ART-21879
Open

ART-21879: Add elliott verify-kernel-tag command#3250
tomasdavidorg wants to merge 4 commits into
openshift-eng:mainfrom
tomasdavidorg:ART-21879

Conversation

@tomasdavidorg

@tomasdavidorg tomasdavidorg commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Checks RHCOS builds in advisories for kernel packages with early-kernel-stop-ship Brew tag. Downloads metadata.json from brewroot to find kernel NVRs, then checks Koji tags.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED

Summary by CodeRabbit

  • New Features

    • Added the verify-kernel-tag command to validate kernel builds against stop-ship tags.
    • Supports text and JSON output with per-advisory and overall pass/fail results.
    • Skips advisories without applicable RHCOS builds or kernel packages.
    • Reports configuration, lookup, and verification failures with appropriate command status.
  • Tests

    • Added comprehensive coverage for configuration, metadata parsing, tag verification, error handling, and output formats.

Checks RHCOS builds in advisories for kernel packages with
early-kernel-stop-ship Brew tag. Downloads metadata.json from
brewroot to find kernel NVRs, then checks Koji tags.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 7, 2026
@openshift-ci-robot

openshift-ci-robot commented Aug 7, 2026

Copy link
Copy Markdown

@tomasdavidorg: This pull request references ART-21879 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 sub-task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Checks RHCOS builds in advisories for kernel packages with early-kernel-stop-ship Brew tag. Downloads metadata.json from brewroot to find kernel NVRs, then checks Koji tags.

Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED

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

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

[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 locriandev 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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 25833bb4-5a01-4e74-bd15-9d522a8c26af

📥 Commits

Reviewing files that changed from the base of the PR and between cdcdd5b and 2e143a0.

📒 Files selected for processing (2)
  • elliott/elliottlib/cli/verify_kernel_tag_cli.py
  • elliott/tests/test_verify_kernel_tag_cli.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • elliott/tests/test_verify_kernel_tag_cli.py
  • elliott/elliottlib/cli/verify_kernel_tag_cli.py

Walkthrough

Adds the verify-kernel-tag Elliott command. It loads advisory configuration, checks kernel builds for the configured stop-ship tag, renders text or JSON results, and exits with status 1 when verification fails.

Changes

Kernel tag verification

Layer / File(s) Summary
Verification contracts and configuration
elliott/elliottlib/cli/verify_kernel_tag_cli.py, elliott/tests/test_verify_kernel_tag_cli.py
Adds result dataclasses, status properties, configuration parsing, advisory lookup, and tests for result states and configuration handling.
Build metadata and tag checks
elliott/elliottlib/cli/verify_kernel_tag_cli.py, elliott/tests/test_verify_kernel_tag_cli.py
Filters RHCOS builds, extracts kernel RPM NVRs from Brewroot metadata, checks Brew or Koji stop-ship tags, and tests lookup outcomes.
Advisory verification and CLI wiring
elliott/elliottlib/cli/verify_kernel_tag_cli.py, elliott/elliottlib/cli/__main__.py, elliott/tests/test_verify_kernel_tag_cli.py
Adds asynchronous advisory verification, skip and error handling, result aggregation, Click command registration, and orchestration tests.
Result rendering and validation
elliott/elliottlib/cli/verify_kernel_tag_cli.py, elliott/tests/test_verify_kernel_tag_cli.py
Adds text and JSON rendering for advisory and overall results, with tests for passed, failed, skipped, and error states.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ElliottCLI
  participant AsyncErrataAPI
  participant Brewroot
  participant Koji
  User->>ElliottCLI: run verify-kernel-tag
  ElliottCLI->>AsyncErrataAPI: retrieve advisory builds
  ElliottCLI->>Brewroot: retrieve RHCOS metadata
  Brewroot-->>ElliottCLI: return kernel RPM NVRs
  ElliottCLI->>Koji: check stop-ship tags
  Koji-->>ElliottCLI: return tag status
  ElliottCLI-->>User: render text or JSON result
Loading

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error, 2 warnings)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error The new DEBUG log records the full Brew metadata URL; BREW_DOWNLOAD_URL is https://download.devel.redhat.com/brewroot, exposing an internal hostname in logs. Do not log the full URL. Log a redacted path or build identifier, and review exception logging to prevent URLs or credentials from appearing.
Docstring Coverage ⚠️ Warning Docstring coverage is 1.61% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ai-Attribution ⚠️ Warning AI use is explicit, but the PR description and all four feature commits use Co-Authored-By: Claude Opus 4.6; no Assisted-by or Generated-by trailer is present. Replace the AI Co-Authored-By trailers with the required Red Hat Assisted-by or Generated-by attribution trailer in the PR commits.
✅ Passed checks (8 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the new elliott verify-kernel-tag command and includes the related Jira issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Weak-Crypto ✅ Passed The added CLI code and tests contain no MD5, SHA1, DES, 3DES, RC4, Blowfish, ECB, custom crypto, or secret-comparison logic.
Container-Privileges ✅ Passed The PR changes only Python source and tests; it adds no container/Kubernetes manifests or privileged settings such as hostPID, hostNetwork, SYS_ADMIN, or allowPrivilegeEscalation.
No-Hardcoded-Secrets ✅ Passed Changed files contain no secret-like assignments, credential-bearing URLs, or base64 literals over 32 characters; Brew endpoints use repository constants without embedded credentials.
No-Injection-Vectors ✅ Passed The new CLI uses validated URL construction, HTTP/Koji APIs, and JSON serialization; scans found no SQL concatenation, shell execution, eval/exec, pickle, unsafe YAML, or HTML injection.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 4

🧹 Nitpick comments (2)
elliott/elliottlib/cli/verify_kernel_tag_cli.py (2)

99-104: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider retrying transient brewroot failures.

A single transient network error or HTTP 5xx marks the advisory as errored. The command then exits with code 1 and reports a false stop-ship failure. Add a bounded retry with backoff for connection errors and 5xx responses.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@elliott/elliottlib/cli/verify_kernel_tag_cli.py` around lines 99 - 104,
Update get_kernel_rpms_from_rhcos to retry requests that fail with connection
errors or HTTP 5xx responses, using a bounded number of attempts and backoff
between retries. Preserve immediate propagation for other HTTP errors, and only
call raise_for_status after a successful or non-retriable response.

83-85: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Malformed NVRs produce a silently wrong URL.

If rhcos_nvr does not match the pattern, re.sub returns the input unchanged. The function then builds a URL without version and release segments. The failure surfaces later as an opaque HTTP 404. Also, an NVR that contains / or .. alters the request path.

Match explicitly and reject input that does not conform.

♻️ Proposed refactor
 def nvr_to_brewroot_metadata_url(rhcos_nvr: str) -> str:
-    path = re.sub(r"-([\d.]+)-(\d+)$", r"/\1/\2", rhcos_nvr)
-    return f"{BREW_DOWNLOAD_URL}/packages/{path}/metadata.json"
+    match = re.fullmatch(r"([A-Za-z0-9_.+-]+?)-([\d.]+)-(\d+)", rhcos_nvr)
+    if not match:
+        raise ValueError(f"Cannot parse RHCOS NVR: {rhcos_nvr}")
+    name, version, release = match.groups()
+    return f"{BREW_DOWNLOAD_URL}/packages/{name}/{version}/{release}/metadata.json"
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@elliott/elliottlib/cli/verify_kernel_tag_cli.py` around lines 83 - 85, Update
nvr_to_brewroot_metadata_url to explicitly validate that rhcos_nvr matches the
expected name-version-release pattern before constructing the URL. Reject
malformed values instead of allowing re.sub to return the unchanged input, and
reject values containing path traversal or slash characters such as "/" or "..".
Preserve the existing URL format for valid NVRs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@elliott/elliottlib/cli/verify_kernel_tag_cli.py`:
- Around line 68-76: Define the intended multiple-tag contract in
get_kernel_packages_and_tag: either return a package-to-tag mapping or raise
when rpm_deliveries contain conflicting stop_ship_tag values, rather than
silently retaining the last tag. Update
elliott/elliottlib/cli/verify_kernel_tag_cli.py:68-76 accordingly, and update
elliott/tests/test_verify_kernel_tag_cli.py:162-168 to assert the tag1/tag2
behavior and use the tag variable.
- Around line 151-154: Update the no-kernel-RPM branch in the advisory
verification flow to fail closed instead of setting result.skipped and returning
a passing outcome. Treat an RHCOS build with no matching kernel packages as an
error, or at minimum record a visible warning consumed by the rendered output,
while preserving normal handling when kernel RPMs are found.

In `@elliott/tests/test_verify_kernel_tag_cli.py`:
- Around line 162-168: Update test_multiple_entries to assert the returned tag
from get_kernel_packages_and_tag, after confirming the intended tag-collapse
behavior for entries with tag1 and tag2 in get_kernel_packages_and_tag. Use that
expected value in an assertion so the unpacked tag is validated rather than
unused.
- Around line 252-258: Update test_http_error to assert
requests.exceptions.HTTPError rather than the broad Exception type, and verify
the raised exception message contains “404 Not Found” using the context-manager
result. Keep the existing mocked raise_for_status behavior and
get_kernel_rpms_from_rhcos invocation unchanged.

---

Nitpick comments:
In `@elliott/elliottlib/cli/verify_kernel_tag_cli.py`:
- Around line 99-104: Update get_kernel_rpms_from_rhcos to retry requests that
fail with connection errors or HTTP 5xx responses, using a bounded number of
attempts and backoff between retries. Preserve immediate propagation for other
HTTP errors, and only call raise_for_status after a successful or non-retriable
response.
- Around line 83-85: Update nvr_to_brewroot_metadata_url to explicitly validate
that rhcos_nvr matches the expected name-version-release pattern before
constructing the URL. Reject malformed values instead of allowing re.sub to
return the unchanged input, and reject values containing path traversal or slash
characters such as "/" or "..". Preserve the existing URL format for valid NVRs.
🪄 Autofix

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: openshift-eng/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 6b37cac3-163a-4a7d-9013-c040fa1d52ba

📥 Commits

Reviewing files that changed from the base of the PR and between 925abe1 and 27ea136.

📒 Files selected for processing (3)
  • elliott/elliottlib/cli/__main__.py
  • elliott/elliottlib/cli/verify_kernel_tag_cli.py
  • elliott/tests/test_verify_kernel_tag_cli.py

Comment thread elliott/elliottlib/cli/verify_kernel_tag_cli.py Outdated
Comment thread elliott/elliottlib/cli/verify_kernel_tag_cli.py
Comment thread elliott/tests/test_verify_kernel_tag_cli.py Outdated
Comment thread elliott/tests/test_verify_kernel_tag_cli.py Outdated
- Validate conflicting stop_ship_tag values across rpm_deliveries entries
- Fail closed (error) instead of open (skip) when no kernel RPMs found
- Use specific HTTPError type in test assertions
- Split test_multiple_entries into same-tag and different-tag cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
Reject malformed NVRs with ValueError instead of silently producing
a wrong URL that would fail later with an opaque 404.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
@openshift-ci

openshift-ci Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

@tomasdavidorg: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/security 2e143a0 link false /test security

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.

2 participants