Skip to content

NO-JIRA: Fix iterating over stream.Status.Tags#2307

Open
vincentdephily wants to merge 1 commit into
openshift:mainfrom
vincentdephily:vdp-iter-stream-status-tags
Open

NO-JIRA: Fix iterating over stream.Status.Tags#2307
vincentdephily wants to merge 1 commit into
openshift:mainfrom
vincentdephily:vdp-iter-stream-status-tags

Conversation

@vincentdephily

@vincentdephily vincentdephily commented Jul 9, 2026

Copy link
Copy Markdown

Iteration is over an []T, not a map[string]T, tag string is in T.Tag.

Only affects log output. Mistake was AFAICT here from the start, but only showed up a typecheck error with go 1.26.

Summary by CodeRabbit

  • Bug Fixes
    • Improved image stream graph handling so tag history is traversed more reliably when building the image relationships.
    • Updated diagnostics: when an expected image is missing, logs now report the correct tag and image reference, simplifying troubleshooting.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jul 9, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

Iteration is over an []T, not a map[string]T, tag string is in T.Tag.

Only affects log output. Mistake was AFAICT here from the start, but only showed up a typecheck error with go 1.26.

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

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: db486896-9b4c-4e50-b5d0-49f709d70c22

📥 Commits

Reviewing files that changed from the base of the PR and between 9fa3021 and d5b1306.

📒 Files selected for processing (1)
  • pkg/cli/admin/top/graph.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/cli/admin/top/graph.go

Walkthrough

addImageStreamsToGraph now directly iterates image stream histories and items, while using the current history and image item for missing-image logging.

Changes

Image Stream Graph Updates

Layer / File(s) Summary
History iteration and logging
pkg/cli/admin/top/graph.go
The loops use direct history and image-item ranges, and missing-image logs use history.Tag and image.DockerImageReference.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Suggested reviewers: ingvagabund


Important

Pre-merge checks failed

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

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Sensitive-Data-In-Logs ❌ Error FAIL: addImageStreamsToGraph logs image.DockerImageReference, which can include internal registry hostnames; redaction is needed. Drop dockerImageReference from the log or redact the registry/host portion before emitting this V(2) message.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (13 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: fixing iteration over stream.Status.Tags.
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.
Stable And Deterministic Test Names ✅ Passed Only pkg/cli/admin/top/graph.go changed; no *_test.go files or Ginkgo titles were added or edited, so the check is not applicable.
Test Structure And Quality ✅ Passed PR only changes pkg/cli/admin/top/graph.go; no test files or Ginkgo specs were modified, so the test-quality criteria aren’t applicable.
Microshift Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; HEAD only changes pkg/cli/admin/top/graph.go, so MicroShift compatibility isn’t implicated.
Single Node Openshift (Sno) Test Compatibility ✅ Passed Only pkg/cli/admin/top/graph.go changed; no new Ginkgo tests or test files were added, so there’s no SNO multi-node compatibility risk.
Topology-Aware Scheduling Compatibility ✅ Passed Only pkg/cli/admin/top/graph.go changed, and it tweaks ImageStream graph logging/iteration; no manifests, controllers, or scheduling constraints were added.
Ote Binary Stdout Contract ✅ Passed Touched code only adjusts klog.Infof fields in a helper; no main/init/suite stdout writes were added or changed.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR only changes pkg/cli/admin/top/graph.go; no new Ginkgo/e2e tests, IPv4-only logic, or external connectivity requirements were added.
No-Weak-Crypto ✅ Passed The only code change is in addImageStreamsToGraph logging/iteration; no weak-crypto APIs, custom crypto, or secret comparisons were added.
Container-Privileges ✅ Passed PASS: The PR only changes pkg/cli/admin/top/graph.go; no container/K8s manifests or privilege-related fields are introduced.
✨ 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.

@tchap

tchap commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

/lgtm

We will need to verify this manually, I guess.

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 10, 2026
@vincentdephily

Copy link
Copy Markdown
Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@vincentdephily

Copy link
Copy Markdown
Author

@tchap Retriggered the AI review, if that what you alluded to with "verified manually". Though IMHO the AI missed the main point of the fix : the old code used to log("tag=%q", array_index), which was rather unhelpful.

@tchap

tchap commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Retriggered the AI review, if that what you alluded to with "verified manually". Though IMHO the AI missed the main point of the fix : the old code used to log("tag=%q", array_index), which was rather unhelpful.

I mean that there is no unit test, so pls label it as verified when you test it manually.

@ardaguclu ardaguclu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not sure what is the main motivation of this PR. Can you please post an example of previous log and current log?

Comment thread pkg/cli/admin/top/graph.go Outdated
@vincentdephily
vincentdephily force-pushed the vdp-iter-stream-status-tags branch from fc158ac to 9fa3021 Compare July 13, 2026 09:52
@openshift-ci openshift-ci Bot removed the lgtm Indicates that a PR is ready to be merged. label Jul 13, 2026
@openshift-ci

openshift-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

New changes are detected. LGTM label has been removed.

It's an `[]T`, not a `map[string]T`, tag string is in `T.Tag`. Only affects log output.
Mistake was AFAICT here from the start, but only showed up a typecheck error with go 1.26.
@vincentdephily
vincentdephily force-pushed the vdp-iter-stream-status-tags branch from 9fa3021 to d5b1306 Compare July 13, 2026 09:54
@vincentdephily

vincentdephily commented Jul 13, 2026

Copy link
Copy Markdown
Author

I'm not sure what is the main motivation of this PR. Can you please post an example of previous log and current log?

The initial motivation is a miscompilation with go 1.26 (an over-eager attempt, I won't actually be going there), which warns about formatting integers with %q. And the realization that the original code didn't do what it intended to (it logged the event number converted to ascii instead of logging the event tag string).

I'm spinning a cluster up to check the output, though I'm not sure of how to hit that specific usecase. I expect a log with from tag="somestring" instead of the previous from tag='\x00'.

if imageNode == nil {
klog.V(2).Infof("Unable to find image %q in graph (from tag=%q, dockerImageReference=%s)",
history.Items[i].Image, tag, image.DockerImageReference)
image.Image, history.Tag, image.DockerImageReference)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does content of history.Tag differ from tag?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

  • The original iteration was for tag, history := range stream.Status.Tags
  • stream.Status.Tags is a []imagev1.NamedTagEventList
  • So tag in the original code is an integer, the position in the array
  • The original code probably expected to be looping over a map with the tag as keys and NamedTagEventList as values
  • Blame Go iteration API for the footgun. Claude kept hallucinating the same way as the original code.

@vincentdephily

Copy link
Copy Markdown
Author

I'm spinning a cluster up to check the output, though I'm not sure of how to hit that specific usecase.

I wasn't sure how to get into a state where imageNode == nil, so here's the log with the Infof() moved outside the if:

Original:

$ ./oc adm top imagestreams --kubeconfig ~/tokill/cluster-bot-2026-07-13-094742.kubeconfig --v=2
[...]
I0713 11:46:08.595076  360463 graph.go:74] Looking at image "sha256:ebc4962c5b44edd3a80cac3b202021c30f9702c59aee42dc0acc16429231e84e" in graph (from tag='\x00', dockerImageReference=quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:ebc4962c5b44edd3a80cac3b202021c30f9702c59aee42dc0acc16429231e84e)
I0713 11:46:08.595123  360463 graph.go:74] Looking at image "sha256:fb9d2b0ab694fd5bd2325d717e4d415fe9caa2bf34ff99c9f38502bc00778fff" in graph (from tag='\x00', dockerImageReference=quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:fb9d2b0ab694fd5bd2325d717e4d415fe9caa2bf34ff99c9f38502bc00778fff)
I0713 11:46:08.595136  360463 graph.go:74] Looking at image "sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a" in graph (from tag='\x00', dockerImageReference=registry.access.redhat.com/ubi9/dotnet-100@sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a)
I0713 11:46:08.595146  360463 graph.go:74] Looking at image "sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a" in graph (from tag='\x01', dockerImageReference=registry.access.redhat.com/ubi9/dotnet-100@sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a)

Patched:

$ ./oc adm top imagestreams --kubeconfig ~/tokill/cluster-bot-2026-07-13-094742.kubeconfig --v=2
[...]
I0713 11:44:49.918589  358934 graph.go:74] Looking at image "sha256:ebc4962c5b44edd3a80cac3b202021c30f9702c59aee42dc0acc16429231e84e" in graph (from tag="latest", dockerImageReference=quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:ebc4962c5b44edd3a80cac3b202021c30f9702c59aee42dc0acc16429231e84e)
I0713 11:44:49.918634  358934 graph.go:74] Looking at image "sha256:fb9d2b0ab694fd5bd2325d717e4d415fe9caa2bf34ff99c9f38502bc00778fff" in graph (from tag="latest", dockerImageReference=quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:fb9d2b0ab694fd5bd2325d717e4d415fe9caa2bf34ff99c9f38502bc00778fff)
I0713 11:44:49.918654  358934 graph.go:74] Looking at image "sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a" in graph (from tag="10.0", dockerImageReference=registry.access.redhat.com/ubi9/dotnet-100@sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a)
I0713 11:44:49.918667  358934 graph.go:74] Looking at image "sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a" in graph (from tag="10.0-ubi9", dockerImageReference=registry.access.redhat.com/ubi9/dotnet-100@sha256:ca21a4d4f70f87c4582a6f5b4463e61c996fb34684985c6622a743560ae10e4a)

If you prefer, I could probably augment TestImageStreamsTop() to capture and check the log output ?

for i := range history.Items {
image := history.Items[i]
for _, history := range stream.Status.Tags {
for i, image := range history.Items {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need i?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

				edgeKind := ImageStreamImageEdgeKind
				if i > 0 {
					edgeKind = HistoricImageStreamImageEdgeKind
				}
				g.AddEdge(imageStreamNode, imageNode, edgeKind)

I suppose there are other ways to write this, but I just wanted a minimal patch, not touching the logic.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

That makes sense

@ardaguclu

Copy link
Copy Markdown
Member

/approve
/retest

@openshift-ci

openshift-ci Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ardaguclu, tchap, vincentdephily

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 Jul 13, 2026
@vincentdephily

Copy link
Copy Markdown
Author

/retest

@vincentdephily

Copy link
Copy Markdown
Author

CI looks resource-starved.

@vincentdephily

Copy link
Copy Markdown
Author

/retest

1 similar comment
@vincentdephily

Copy link
Copy Markdown
Author

/retest

@vincentdephily

Copy link
Copy Markdown
Author

/retest

@openshift-ci

openshift-ci Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

@vincentdephily: 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/okd-scos-images d5b1306 link true /test okd-scos-images

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

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants