Skip to content

OCPQE-31468: verify images command log pollution#1262

Merged
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
kuiwang02:checkimagessubcmd
Mar 20, 2026
Merged

OCPQE-31468: verify images command log pollution#1262
openshift-merge-bot[bot] merged 1 commit intoopenshift:mainfrom
kuiwang02:checkimagessubcmd

Conversation

@kuiwang02
Copy link
Contributor

/cc @jianzhangbjz @Xia-Zhao-rh @bandrade

Problem

The images command outputs logs instead of pure JSON, causing parsing failures in openshift-tests:

I0319 16:12:15.325526 26159 client.go:1222] Found admin context: admin
I0319 16:12:15.325676 26159 client.go:1237] Cached admin context for all test suites: admin
null

This caused PR #1256 to be reverted by PR #1258.

Root Cause

admContextName initialization in NewCLI() executes during test tree construction (when running images/list commands), triggering e2e.Logf() calls that pollute the output.

Solution

  1. Lazy-loading pattern: Initialize admContextName on first AsAdmin() call instead of in constructor (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  2. Verbose parameter: Add verbose bool to duplicateFileToTempOrEmpty() to control logging (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  3. JSON validation: Add hack/verify-images-json.sh and CI integration to prevent future regressions

Assisted-By: Claude Code

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

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

Details

In response to this:

/cc @jianzhangbjz @Xia-Zhao-rh @bandrade

Problem

The images command outputs logs instead of pure JSON, causing parsing failures in openshift-tests:

I0319 16:12:15.325526 26159 client.go:1222] Found admin context: admin
I0319 16:12:15.325676 26159 client.go:1237] Cached admin context for all test suites: admin
null

This caused PR #1256 to be reverted by PR #1258.

Root Cause

admContextName initialization in NewCLI() executes during test tree construction (when running images/list commands), triggering e2e.Logf() calls that pollute the output.

Solution

  1. Lazy-loading pattern: Initialize admContextName on first AsAdmin() call instead of in constructor (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  2. Verbose parameter: Add verbose bool to duplicateFileToTempOrEmpty() to control logging (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  3. JSON validation: Add hack/verify-images-json.sh and CI integration to prevent future regressions

Assisted-By: Claude Code

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

coderabbitai bot commented Mar 19, 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: d01c75b7-208e-47d7-9abf-ba3c16c7d416

📥 Commits

Reviewing files that changed from the base of the PR and between 07583c8 and 0403d02.

📒 Files selected for processing (2)
  • tests-extension/Makefile
  • tests-extension/hack/verify-images-json.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests-extension/Makefile
  • tests-extension/hack/verify-images-json.sh

Walkthrough

Adds a new script to validate that the images subcommand emits strict JSON (no interleaved logs) and updates the tests-extension Makefile to run that validation as part of the verify-metadata workflow.

Changes

Cohort / File(s) Summary
Makefile targets
tests-extension/Makefile
Introduce verify-images-json phony target and add it as a dependency of verify-metadata so JSON validation runs before the git diff --exit-code $(METADATA) check.
JSON validation script
tests-extension/hack/verify-images-json.sh
New executable script that locates the test binary (default .../bin/olmv0-tests-ext), captures images subcommand stdout/stderr, and validates the combined output is valid JSON using a small inline Go validator; prints captured output on failure.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

Copy link

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

🧹 Nitpick comments (1)
tests-extension/hack/verify-images-json.sh (1)

35-35: Use single quotes in trap to defer variable expansion.

While this works correctly because tmpdir is already set, single quotes are the idiomatic pattern and prevent issues if the trap is ever moved before the variable assignment.

Suggested fix
-trap "rm -rf ${tmpdir}" EXIT
+trap 'rm -rf "${tmpdir}"' EXIT
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests-extension/hack/verify-images-json.sh` at line 35, Change the trap
invocation so it uses single quotes to defer expansion of the tmpdir variable
(replace trap "rm -rf ${tmpdir}" EXIT with a single-quoted version) so the
removal command references tmpdir at EXIT time rather than at parse time; look
for the trap line that references tmpdir and update the quoting around the rm
-rf ${tmpdir} argument accordingly.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests-extension/hack/verify-images-json.sh`:
- Line 35: Change the trap invocation so it uses single quotes to defer
expansion of the tmpdir variable (replace trap "rm -rf ${tmpdir}" EXIT with a
single-quoted version) so the removal command references tmpdir at EXIT time
rather than at parse time; look for the trap line that references tmpdir and
update the quoting around the rm -rf ${tmpdir} argument accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bd88bf5a-fed1-48ac-941a-77ba6c42b00d

📥 Commits

Reviewing files that changed from the base of the PR and between 1667d8c and 07583c8.

📒 Files selected for processing (2)
  • tests-extension/Makefile
  • tests-extension/hack/verify-images-json.sh

@kuiwang02
Copy link
Contributor Author

/test e2e-aws-upgrade-ovn-single-node

@kuiwang02
Copy link
Contributor Author

/test e2e-upgrade

@kuiwang02
Copy link
Contributor Author

kuiwang02 commented Mar 20, 2026

/retitle OCPQE-31468: verify images command log pollution

@openshift-ci openshift-ci bot changed the title NO-ISSUE: verify images command log pollution OCPQE-31468: verify images command log pollution Mar 20, 2026
@openshift-ci-robot
Copy link

openshift-ci-robot commented Mar 20, 2026

@kuiwang02: This pull request references OCPQE-31468 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:

/cc @jianzhangbjz @Xia-Zhao-rh @bandrade

Problem

The images command outputs logs instead of pure JSON, causing parsing failures in openshift-tests:

I0319 16:12:15.325526 26159 client.go:1222] Found admin context: admin
I0319 16:12:15.325676 26159 client.go:1237] Cached admin context for all test suites: admin
null

This caused PR #1256 to be reverted by PR #1258.

Root Cause

admContextName initialization in NewCLI() executes during test tree construction (when running images/list commands), triggering e2e.Logf() calls that pollute the output.

Solution

  1. Lazy-loading pattern: Initialize admContextName on first AsAdmin() call instead of in constructor (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  2. Verbose parameter: Add verbose bool to duplicateFileToTempOrEmpty() to control logging (done by OCPBUGS-78557: Re-Apply Fix admin context race condition in parallel tests #1259 )
  3. JSON validation: Add hack/verify-images-json.sh and CI integration to prevent future regressions

Assisted-By: Claude Code

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
Copy link
Contributor

openshift-ci bot commented Mar 20, 2026

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

@kuiwang02
Copy link
Contributor Author

/verified by @kuiwang02

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

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

Details

In response to this:

/verified by @kuiwang02

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.

@jianzhangbjz
Copy link
Member

/approve
/lgtm

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

openshift-ci bot commented Mar 20, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jianzhangbjz, kuiwang02

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

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 20, 2026
@openshift-merge-bot openshift-merge-bot bot merged commit 8e31ecc into openshift:main Mar 20, 2026
16 checks passed
@kuiwang02 kuiwang02 deleted the checkimagessubcmd branch March 20, 2026 05:48
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