Skip to content

NO-JIRA: Improve must-gather image handling and annotation checks- #2071 - #2071

Open
midu16 wants to merge 6 commits into
openshift:mainfrom
midu16:master
Open

NO-JIRA: Improve must-gather image handling and annotation checks- #2071#2071
midu16 wants to merge 6 commits into
openshift:mainfrom
midu16:master

Conversation

@midu16

@midu16 midu16 commented Aug 7, 2025

Copy link
Copy Markdown
Contributor

Pull Request: Improve must-gather image handling and annotation checks

Summary

This PR enhances the MustGatherOptions.completeImages() method by:

  • Logging warnings for CSVs that are missing the required must-gather-image annotation.
  • Improving robustness and readability of the image collection logic.
  • Ensuring deduplication of default must-gather image when collecting plug-in images.

Changes

  • Moved CSV annotation scanning inline to allow per-CSV warning messages.

  • Added warning log in the format:

    WARNING: CSV operator <name> doesn't have the must-gather-image annotation.
    
  • Enhanced image resolution logic to:

    • Fallback to hardcoded must-gather image if the image stream tag cannot be resolved.
    • Log warnings for such fallbacks.
  • Maintained support for --all (aka AllImages) by collecting images from both:

    • CSVs (ClusterServiceVersions)
    • ClusterOperators
  • Ensured duplicate images (especially the default one) are not added to the final list.

Testing

  • Verified that missing annotations on CSVs produce proper warning output.
  • Confirmed image collection and deduplication works as expected.
  • Manually validated fallback logic for missing default image stream tag.

Related

  • Annotation key used: operators.openshift.io/must-gather-image
  • Fulfills a need for better diagnostics and operator plug-in visibility in oc adm must-gather --all-images.

Notes

  • Future enhancement may consider moving CSV image collection into a separate method again, but returning both:

    • pluginImages
    • []string of CSVs missing the annotation for external logging.

@openshift-ci
openshift-ci Bot requested review from atiratree and deads2k August 7, 2025 16:01
@coderabbitai

coderabbitai Bot commented Sep 17, 2025

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

When --all-images is set (or no images provided), the must-gather flow resolves the default must-gather image, lists CSVs and ClusterOperators to collect mgAnnotation values, warns for CSVs missing the annotation, removes the default image from discovered results to avoid duplication, and appends discovered images to o.Images.

Changes

Cohort / File(s) Summary
Must-gather image discovery and defaults
pkg/cli/admin/mustgather/mustgather.go
Ensures default must-gather image is resolved when no images or --all-images is set; when --all-images is active, lists CSVs and ClusterOperators to gather mgAnnotation values, logs warnings for CSVs without the annotation, wraps list errors with contextual messages (failed to list CSVs: %v, failed to list ClusterOperators: %v), removes the resolved default from discovered plugins to avoid duplicates, appends discovered images to o.Images, and updates logging/formatting.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: improved must-gather image handling and annotation checks.
✨ 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

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
pkg/cli/admin/mustgather/mustgather.go (2)

273-276: Make fallback explicit and avoid double newline in log.

Current o.log("%v\n", err) adds two newlines and doesn’t state that a fallback is used.

Apply this diff:

-        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
-            o.log("%v\n", err)
-            image = "registry.redhat.io/openshift4/ose-must-gather:latest"
-        }
+        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
+            fallback := "registry.redhat.io/openshift4/ose-must-gather:latest"
+            o.log("WARNING: unable to resolve imagestream openshift/must-gather:latest: %v; falling back to %s", err, fallback)
+            image = fallback
+        }

309-314: Dedup across equivalent pullspecs, not just exact string match.

If a CSV annotates the default image via a different but equivalent reference (e.g., tag vs digest), delete(pluginImages, o.Images[0]) won’t dedupe it.

Consider normalizing with imagereference.Parse and comparing Exact() (or repository+ID) before appending, e.g., parse o.Images[0] once and skip plugin entries that resolve to the same canonical ref.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between fa1bc38 and 4358b67.

📒 Files selected for processing (1)
  • pkg/cli/admin/mustgather/mustgather.go (3 hunks)
🔇 Additional comments (1)
pkg/cli/admin/mustgather/mustgather.go (1)

315-317: Confirm intended UX for duplicate “Using must-gather plug-in image” lines.

This now prints once during Complete() to stdout and again into must-gather.logs in Run(). If that’s unintentional, drop the Complete() log.

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
pkg/cli/admin/mustgather/mustgather.go (3)

269-278: Avoid double newline and log explicit fallback

o.log("%v\n", err) prints two newlines because o.log appends one. Also add an explicit fallback warning for clarity.

Apply this diff:

-        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
-            o.log("%v\n", err)
-            image = "registry.redhat.io/openshift4/ose-must-gather:latest"
-        }
+        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
+            o.log("WARNING: %v", err)
+            fallback := "registry.redhat.io/openshift4/ose-must-gather:latest"
+            o.log("WARNING: falling back to default must-gather image %q", fallback)
+            image = fallback
+        }

Please confirm the intended behavior is to always include the default image when --all-images is set (then add discovered plug-ins), which matches the PR summary.


294-301: Include namespace in per-CSV warning

CSV names can collide across namespaces. Log the fully-qualified ns/name for disambiguation.

Apply this diff:

-        for _, u := range uList.Items {
-            ann := u.GetAnnotations()
-            if v, ok := ann[mgAnnotation]; ok {
-                pluginImages[v] = struct{}{}
-            } else {
-                o.log("WARNING: CSV operator %s doesn't have the must-gather-image annotation.", u.GetName())
-            }
-        }
+        for _, u := range uList.Items {
+            ann := u.GetAnnotations()
+            if v, ok := ann[mgAnnotation]; ok {
+                pluginImages[v] = struct{}{}
+            } else {
+                name := u.GetName()
+                if ns := u.GetNamespace(); ns != "" {
+                    name = ns + "/" + name
+                }
+                o.log("WARNING: CSV operator %s doesn't have the must-gather-image annotation.", name)
+            }
+        }

315-318: Deterministic ordering for appended plug-in images

Appending from a map yields nondeterministic order, which affects logs and pod creation order. Sort for stable output.

Apply this diff:

-        delete(pluginImages, o.Images[0])
-        for i := range pluginImages {
-            o.Images = append(o.Images, i)
-        }
+        delete(pluginImages, o.Images[0])
+        if len(pluginImages) > 0 {
+            extras := make([]string, 0, len(pluginImages))
+            for img := range pluginImages {
+                extras = append(extras, img)
+            }
+            sort.Strings(extras)
+            o.Images = append(o.Images, extras...)
+        }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 4358b67 and 3845d4b.

📒 Files selected for processing (1)
  • pkg/cli/admin/mustgather/mustgather.go (2 hunks)
🔇 Additional comments (4)
pkg/cli/admin/mustgather/mustgather.go (4)

261-268: LGTM: explicit imagestream resolution

No issues spotted in resolving user-provided imagestreams.


284-293: CSV listing via DynamicClient: good

Switch to DynamicClient looks correct; error handling message is clear.


303-307: LGTM: ClusterOperators path and error message

Error message is specific and consistent with the CSV case.


325-345: Remove now-unused annotatedCSVs() helper — safe to delete.
No call sites found; delete the function in pkg/cli/admin/mustgather/mustgather.go (lines ~325–345) or rewire it if it was intended to be used.

midu16 added a commit to midu16/oc that referenced this pull request Sep 17, 2025

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

♻️ Duplicate comments (1)
pkg/cli/admin/mustgather/mustgather.go (1)

284-296: Fix compile error: OperatorClient is not a field; use DynamicClient to list CSVs

MustGatherOptions has no OperatorClient. Use the already-initialized DynamicClient to list CSVs and keep per-CSV warnings.

Apply:

-        // Annotated CSVs
-        csvs, err := o.OperatorClient.OperatorsV1alpha1().ClusterServiceVersions("").List(context.TODO(), metav1.ListOptions{})
-        if err != nil {
-            return fmt.Errorf("failed to list CSVs: %v", err)
-        }
-        for _, csv := range csvs.Items {
-            ann := csv.GetAnnotations()
-            if v, ok := ann[mgAnnotation]; ok {
-                pluginImages[v] = struct{}{}
-            } else {
-                o.log("WARNING: CSV operator %s doesn't have the must-gather-image annotation.", csv.GetName())
-            }
-        }
+        // Annotated CSVs (via dynamic client)
+        csvGVR := schema.GroupVersionResource{
+            Group:    "operators.coreos.com",
+            Version:  "v1alpha1",
+            Resource: "clusterserviceversions",
+        }
+        uList, err := o.DynamicClient.Resource(csvGVR).Namespace(metav1.NamespaceAll).List(context.TODO(), metav1.ListOptions{})
+        if err != nil {
+            return fmt.Errorf("failed to list CSVs: %w", err)
+        }
+        for _, u := range uList.Items {
+            ann := u.GetAnnotations()
+            if v, ok := ann[mgAnnotation]; ok {
+                pluginImages[v] = struct{}{}
+            } else {
+                o.log("WARNING: CSV operator %s doesn't have the must-gather-image annotation.", u.GetName())
+            }
+        }
🧹 Nitpick comments (3)
pkg/cli/admin/mustgather/mustgather.go (3)

269-278: Emit explicit fallback WARNING and avoid double newline in log

  • o.log already appends a newline; passing "%v\n" yields double newlines.
  • Per PR goals, the fallback should clearly log a WARNING that a hardcoded image is used.

Apply:

-        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
-            o.log("%v\n", err)
-            image = "registry.redhat.io/openshift4/ose-must-gather:latest"
-        }
+        if image, err = o.resolveImageStreamTag("openshift", "must-gather", "latest"); err != nil {
+            o.log("WARNING: %v", err)
+            image = "registry.redhat.io/openshift4/ose-must-gather:latest"
+            o.log("WARNING: falling back to default must-gather image %s", image)
+        }

309-314: Make plug-in image ordering deterministic; consider stronger dedup

  • Map iteration order is random; sort for reproducible CLI output and pod ordering.
  • Optional: normalize refs (tag vs digest) before dedup so the default isn’t re-added under a different form.

Apply:

-        for i := range pluginImages {
-            o.Images = append(o.Images, i)
-        }
+        imgs := make([]string, 0, len(pluginImages))
+        for img := range pluginImages {
+            imgs = append(imgs, img)
+        }
+        sort.Strings(imgs)
+        o.Images = append(o.Images, imgs...)

Optional follow-up (separate change): normalize references via imagereference.Parse and compare by digest (when present) to enhance dedup. Verify current CSV annotations’ formats across operators before changing behavior.


315-316: LGTM: summary log of selected images

The consolidated log line is helpful. Keep it; the extra blank line after isn’t needed but harmless.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge base: Disabled due to Reviews -> Disable Knowledge Base setting

📥 Commits

Reviewing files that changed from the base of the PR and between 3845d4b and 8b0bde2.

📒 Files selected for processing (1)
  • pkg/cli/admin/mustgather/mustgather.go (3 hunks)
🔇 Additional comments (2)
pkg/cli/admin/mustgather/mustgather.go (2)

261-268: LGTM: explicit image-stream resolution path

Resolving user-specified imagestream tags up-front is correct and keeps error handling tight.


299-302: Wrap underlying error with %w for better context

Use error wrapping to preserve cause.

[ suggest_nitpick_refactor ]

-        if err != nil {
-            return fmt.Errorf("failed to list ClusterOperators: %v", err)
-        }
+        if err != nil {
+            return fmt.Errorf("failed to list ClusterOperators: %w", err)
+        }

midu16 added a commit to midu16/oc that referenced this pull request Nov 3, 2025
midu16 added a commit to midu16/oc that referenced this pull request Nov 3, 2025
@midu16

midu16 commented Nov 6, 2025

Copy link
Copy Markdown
Contributor Author

@ingvagabund wondering if you can assist on this review, intention here its to improve the logging in the scenario where a given operator doesnt have the must-gather-image annotation within its CSV.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2025
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 26, 2025
@shivprakashmuley

shivprakashmuley commented Dec 6, 2025

Copy link
Copy Markdown

Hi @midu16 , can you please check the CI job failures.
# github.com/openshift/oc/pkg/cli/admin/mustgather
pkg/cli/admin/mustgather/mustgather.go:290:23: undefined: csvs

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@pkg/cli/admin/mustgather/mustgather.go`:
- Around line 290-301: The undefined `csvs` bug is caused by moving CSV
iteration out of annotatedCSVs; restore per-CSV warning logic by changing
annotatedCSVs to accept the logger (e.g., add a parameter for o.log or a func
like logf) and move the loop that inspects csvs.Items and emits warnings using
mgAnnotation into annotatedCSVs; update annotatedCSVs' signature (e.g.,
annotatedCSVs(ctx context.Context, logf func(string, ...interface{}))
(map[string]struct{}, error)), implement the per-CSV warning there when an
annotation is missing, and then call it from mustgather.go as pluginImages, err
= o.annotatedCSVs(ctx, o.log) and remove the orphaned for-loop in mustgather.go;
also update any other callers to match the new signature.

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
@openshift-ci

openshift-ci Bot commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

@midu16: The following tests 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/e2e-metal-ipi-ovn-ipv6 8b0bde2 link false /test e2e-metal-ipi-ovn-ipv6
ci/prow/okd-scos-e2e-aws-ovn 8b0bde2 link false /test okd-scos-e2e-aws-ovn
ci/prow/e2e-aws-certrotation 8b0bde2 link false /test e2e-aws-certrotation

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.

@midu16

midu16 commented Feb 19, 2026

Copy link
Copy Markdown
Contributor Author

Hi @midu16 , can you please check the CI job failures. # github.com/openshift/oc/pkg/cli/admin/mustgather pkg/cli/admin/mustgather/mustgather.go:290:23: undefined: csvs

@shivprakashmuley can you review now ?

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
@midu16

midu16 commented Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

hi @ardaguclu i wonder if you can help me with this PR ?

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

Dropped a few comments. Can you please test this on real OCP cluster and paste the log here to see how many operators lack the annotation, so that we can see what customers see in real cluster.

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
@midu16
midu16 requested a review from ardaguclu July 23, 2026 12:07
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
if o.AllImages {
// find all csvs and clusteroperators with the annotation "operators.openshift.io/must-gather-image"
pluginImages, err := o.annotatedCSVs(ctx)
pluginImages, missingCSVs, err := o.annotatedCSVs(ctx)

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.

Suggested change
pluginImages, missingCSVs, err := o.annotatedCSVs(ctx)
pluginImages, annotationMissingCSVs, err := o.annotatedCSVs(ctx)

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
if err != nil {
return err
}
var missingCOs []string

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.

Suggested change
var missingCOs []string
var annotationMissingCOs []string

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
return nil, nil, err
}

var missingAnnotation []string

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.

Suggested change
var missingAnnotation []string
var annotationMissingImages []string

midu16 and others added 4 commits July 29, 2026 15:18
Return missing annotation names from annotatedCSVs instead of logging
internally, so both ClusterOperator and CSV messages are logged at the
same level in completeImages. Drop the WARNING prefix since the messages
are informational.
Rename missingCOs/missingCSVs to annotationMissingCOs/annotationMissingCSVs
to clarify these track resources missing the must-gather annotation.
Align internal variable naming in annotatedCSVs with the caller-side
convention (annotationMissingCSVs, annotationMissingCOs) per review
feedback.
@ardaguclu

Copy link
Copy Markdown
Member

/label tide/merge-method-squash
/lgtm
/approve

@openshift-ci openshift-ci Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Jul 29, 2026
@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling required tests:
/test e2e-agnostic-ovn-cmd
/test e2e-aws-ovn
/test e2e-aws-ovn-serial-1of2
/test e2e-aws-ovn-serial-2of2
/test e2e-aws-ovn-upgrade

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
@midu16 midu16 changed the title Improve must-gather image handling and annotation checks NO-JRA: Improve must-gather image handling and annotation checks Jul 29, 2026
@ardaguclu

Copy link
Copy Markdown
Member

/retitle NO-JIRA: Improve must-gather image handling and annotation checks- #2071

@ardaguclu

Copy link
Copy Markdown
Member

/retitle NO-JIRA: Improve must-gather image handling and annotation checks

@openshift-ci openshift-ci Bot changed the title NO-JRA: Improve must-gather image handling and annotation checks NO-JIRA: Improve must-gather image handling and annotation checks Jul 29, 2026
@openshift-ci openshift-ci Bot changed the title NO-JIRA: Improve must-gather image handling and annotation checks NO-JIRA: Improve must-gather image handling and annotation checks- #2071 Jul 29, 2026
@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 29, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

Pull Request: Improve must-gather image handling and annotation checks

Summary

This PR enhances the MustGatherOptions.completeImages() method by:

  • Logging warnings for CSVs that are missing the required must-gather-image annotation.
  • Improving robustness and readability of the image collection logic.
  • Ensuring deduplication of default must-gather image when collecting plug-in images.

Changes

  • Moved CSV annotation scanning inline to allow per-CSV warning messages.
  • Added warning log in the format:
WARNING: CSV operator <name> doesn't have the must-gather-image annotation.
  • Enhanced image resolution logic to:

  • Fallback to hardcoded must-gather image if the image stream tag cannot be resolved.

  • Log warnings for such fallbacks.

  • Maintained support for --all (aka AllImages) by collecting images from both:

  • CSVs (ClusterServiceVersions)

  • ClusterOperators

  • Ensured duplicate images (especially the default one) are not added to the final list.

Testing

  • Verified that missing annotations on CSVs produce proper warning output.
  • Confirmed image collection and deduplication works as expected.
  • Manually validated fallback logic for missing default image stream tag.

Related

  • Annotation key used: operators.openshift.io/must-gather-image
  • Fulfills a need for better diagnostics and operator plug-in visibility in oc adm must-gather --all-images.

Notes

  • Future enhancement may consider moving CSV image collection into a separate method again, but returning both:

  • pluginImages

  • []string of CSVs missing the annotation for external logging.

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.

@midu16

midu16 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

/verified by @midu16

test_must_gather_annotation_warning.sh

Must-Gather Annotation Warning — Test Results

Date: 2026-07-31
Binary: ./oc (v4.2.0-alpha.0-3022-gafbcfb7, commit afbcfb7)
Cluster: OpenShift 4.18.27 (KUBECONFIG=./kubeconfig, user system:admin)

Changes Under Test

Commits cf8b4e273..afbcfb7cf modified oc adm must-gather --all-images to log informational warnings when ClusterOperators or CSVs lack the operators.openshift.io/must-gather-image annotation. Previously these operators were silently skipped.

Commit Description
cf8b4e2 Fix undefined csvs in mustgather and add CSV annotation warning
2c804f3 Move missing-annotation logging to caller
4b4339a Improve missing-annotation variable naming
afbcfb7 Rename missingAnnotation to annotationMissingImages

Cluster State

Resource With Annotation Without Annotation
ClusterOperators 0 34
CSVs (unique names) 5 12

Annotated CSV Images

CSV Image
advanced-cluster-management.v2.13.10 registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f01...
oadp-operator.v1.4.10 registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:870009...
local-storage-operator.v4.18.0-202607171826 registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72be...
cluster-logging.v6.2.12 registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f27...
ocs-operator.v4.18.25-rhodf registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bb...

Test Results

# Test Result
1 ClusterOperator annotation warning line is present PASS
2 All 34 unannotated ClusterOperators listed in warning PASS
3 CSV annotation warning line is present PASS
4 All 12 unique unannotated CSV names appear in warning PASS
5 Using must-gather plug-in image line is present PASS
6 All 5 annotated CSV images included in plug-in list PASS
7 ClusterOperator warning appears before image list (line 1 < 3) PASS
8 CSV warning appears before image list (line 2 < 3) PASS

8 passed, 0 failed

Log Output: Before vs After

Before (commit a4c90c7, no annotation warnings)

No indication of which operators lack the must-gather-image annotation. The output jumps
straight from image resolution to the cluster summary and pod creation:

[must-gather      ] OUT 2026-07-31T08:35:39.025348396Z Using must-gather plug-in image:
    quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d...,
    registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900...,
    registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb...,
    registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752...,
    registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bbde...,
    registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f016d...
When opening a support case, bugzilla, or issue please include the following summary data
along with any other requested information:
ClusterID: 6bb33e72-07a1-4284-ab9f-05516d469689
ClientVersion: unknown
ClusterVersion: Stable at "4.18.27"
ClusterOperators:
	All healthy and stable


[must-gather      ] OUT 2026-07-31T08:35:39.482811773Z namespace/openshift-must-gather-nc4wq created
[must-gather      ] OUT 2026-07-31T08:35:39.614929398Z clusterrolebinding.rbac.authorization.k8s.io/must-gather-sd7bk created
[must-gather      ] OUT 2026-07-31T08:35:39.907347642Z pod for plug-in image
    registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752... created
[must-gather      ] OUT 2026-07-31T08:35:39.90738414Z pod for plug-in image
    registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb... created
[must-gather      ] OUT 2026-07-31T08:35:39.911311106Z pod for plug-in image
    registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900... created
[must-gather      ] OUT 2026-07-31T08:35:39.911372451Z pod for plug-in image
    quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d... created

After (commit afbcfb7, with annotation warnings)

Two new informational lines appear before the Using must-gather plug-in image line,
listing every ClusterOperator and CSV that lacks the operators.openshift.io/must-gather-image
annotation:

[must-gather      ] OUT 2026-07-31T08:34:48.344870563Z ClusterOperators without
    operators.openshift.io/must-gather-image annotation: authentication, baremetal,
    cloud-controller-manager, cloud-credential, cluster-autoscaler, config-operator, console,
    control-plane-machine-set, csi-snapshot-controller, dns, etcd, image-registry, ingress,
    insights, kube-apiserver, kube-controller-manager, kube-scheduler,
    kube-storage-version-migrator, machine-api, machine-approver, machine-config, marketplace,
    monitoring, network, node-tuning, olm, openshift-apiserver, openshift-controller-manager,
    openshift-samples, operator-lifecycle-manager, operator-lifecycle-manager-catalog,
    operator-lifecycle-manager-packageserver, service-ca, storage
[must-gather      ] OUT 2026-07-31T08:34:48.344962054Z CSVs without
    operators.openshift.io/must-gather-image annotation: openshift-gitops-operator.v1.15.4,
    topology-aware-lifecycle-manager.v4.18.5, packageserver,
    cephcsi-operator.v4.18.25-rhodf, mcg-operator.v4.18.25-rhodf,
    ocs-client-operator.v4.18.25-rhodf, odf-csi-addons-operator.v4.18.25-rhodf,
    odf-dependencies.v4.18.25-rhodf, odf-operator.v4.18.25-rhodf,
    odf-prometheus-operator.v4.18.25-rhodf, recipe.v4.18.25-rhodf,
    rook-ceph-operator.v4.18.25-rhodf, ...
[must-gather      ] OUT 2026-07-31T08:34:48.344978555Z Using must-gather plug-in image:
    quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d...,
    registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900...,
    registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb...,
    registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752...,
    registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bbde...,
    registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f016d...
When opening a support case, bugzilla, or issue please include the following summary data
along with any other requested information:
ClusterID: 6bb33e72-07a1-4284-ab9f-05516d469689
ClientVersion: unknown
ClusterVersion: Stable at "4.18.27"
ClusterOperators:
	All healthy and stable


[must-gather      ] OUT 2026-07-31T08:34:48.811666519Z namespace/openshift-must-gather-g74xh created
[must-gather      ] OUT 2026-07-31T08:34:48.959852123Z clusterrolebinding.rbac.authorization.k8s.io/must-gather-qkk4f created
[must-gather      ] OUT 2026-07-31T08:34:49.259808718Z pod for plug-in image
    registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900... created
[must-gather      ] OUT 2026-07-31T08:34:49.268102002Z pod for plug-in image
    registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752... created
[must-gather      ] OUT 2026-07-31T08:34:49.268135525Z pod for plug-in image
    quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d... created
[must-gather      ] OUT 2026-07-31T08:34:49.268271219Z pod for plug-in image
    registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb... created

Key Differences

Aspect Before After
ClusterOperator missing-annotation warning Not emitted Emitted before image list
CSV missing-annotation warning Not emitted Emitted before image list
Using must-gather plug-in image line First output line Third output line
Logging format [must-gather] OUT <timestamp> <message> Same format, consistent
Image selection Unchanged Unchanged
Pod creation Unchanged Unchanged

How to Reproduce

make oc   # or: go build -mod=vendor -tags 'include_gcs include_oss containers_image_openpgp' -o ./oc ./cmd/oc/
export KUBECONFIG=./kubeconfig
bash ./test_must_gather_annotation_warning.sh

@openshift-ci-robot openshift-ci-robot added the verified Signifies that the PR passed pre-merge verification criteria label Jul 31, 2026
@openshift-ci-robot

Copy link
Copy Markdown

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

Details

In response to this:

/verified by @midu16

test_must_gather_annotation_warning.sh

Must-Gather Annotation Warning — Test Results

Date: 2026-07-31
Binary: ./oc (v4.2.0-alpha.0-3022-gafbcfb7, commit afbcfb7)
Cluster: OpenShift 4.18.27 (KUBECONFIG=./kubeconfig, user system:admin)

Changes Under Test

Commits cf8b4e273..afbcfb7cf modified oc adm must-gather --all-images to log informational warnings when ClusterOperators or CSVs lack the operators.openshift.io/must-gather-image annotation. Previously these operators were silently skipped.

Commit Description
cf8b4e2 Fix undefined csvs in mustgather and add CSV annotation warning
2c804f3 Move missing-annotation logging to caller
4b4339a Improve missing-annotation variable naming
afbcfb7 Rename missingAnnotation to annotationMissingImages

Cluster State

Resource With Annotation Without Annotation
ClusterOperators 0 34
CSVs (unique names) 5 12

Annotated CSV Images

CSV Image
advanced-cluster-management.v2.13.10 registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f01...
oadp-operator.v1.4.10 registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:870009...
local-storage-operator.v4.18.0-202607171826 registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72be...
cluster-logging.v6.2.12 registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f27...
ocs-operator.v4.18.25-rhodf registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bb...

Test Results

# Test Result
1 ClusterOperator annotation warning line is present PASS
2 All 34 unannotated ClusterOperators listed in warning PASS
3 CSV annotation warning line is present PASS
4 All 12 unique unannotated CSV names appear in warning PASS
5 Using must-gather plug-in image line is present PASS
6 All 5 annotated CSV images included in plug-in list PASS
7 ClusterOperator warning appears before image list (line 1 < 3) PASS
8 CSV warning appears before image list (line 2 < 3) PASS

8 passed, 0 failed

Log Output: Before vs After

Before (commit a4c90c7, no annotation warnings)

No indication of which operators lack the must-gather-image annotation. The output jumps
straight from image resolution to the cluster summary and pod creation:

[must-gather      ] OUT 2026-07-31T08:35:39.025348396Z Using must-gather plug-in image:
   quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d...,
   registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900...,
   registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb...,
   registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752...,
   registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bbde...,
   registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f016d...
When opening a support case, bugzilla, or issue please include the following summary data
along with any other requested information:
ClusterID: 6bb33e72-07a1-4284-ab9f-05516d469689
ClientVersion: unknown
ClusterVersion: Stable at "4.18.27"
ClusterOperators:
  All healthy and stable


[must-gather      ] OUT 2026-07-31T08:35:39.482811773Z namespace/openshift-must-gather-nc4wq created
[must-gather      ] OUT 2026-07-31T08:35:39.614929398Z clusterrolebinding.rbac.authorization.k8s.io/must-gather-sd7bk created
[must-gather      ] OUT 2026-07-31T08:35:39.907347642Z pod for plug-in image
   registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752... created
[must-gather      ] OUT 2026-07-31T08:35:39.90738414Z pod for plug-in image
   registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb... created
[must-gather      ] OUT 2026-07-31T08:35:39.911311106Z pod for plug-in image
   registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900... created
[must-gather      ] OUT 2026-07-31T08:35:39.911372451Z pod for plug-in image
   quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d... created

After (commit afbcfb7, with annotation warnings)

Two new informational lines appear before the Using must-gather plug-in image line,
listing every ClusterOperator and CSV that lacks the operators.openshift.io/must-gather-image
annotation:

[must-gather      ] OUT 2026-07-31T08:34:48.344870563Z ClusterOperators without
   operators.openshift.io/must-gather-image annotation: authentication, baremetal,
   cloud-controller-manager, cloud-credential, cluster-autoscaler, config-operator, console,
   control-plane-machine-set, csi-snapshot-controller, dns, etcd, image-registry, ingress,
   insights, kube-apiserver, kube-controller-manager, kube-scheduler,
   kube-storage-version-migrator, machine-api, machine-approver, machine-config, marketplace,
   monitoring, network, node-tuning, olm, openshift-apiserver, openshift-controller-manager,
   openshift-samples, operator-lifecycle-manager, operator-lifecycle-manager-catalog,
   operator-lifecycle-manager-packageserver, service-ca, storage
[must-gather      ] OUT 2026-07-31T08:34:48.344962054Z CSVs without
   operators.openshift.io/must-gather-image annotation: openshift-gitops-operator.v1.15.4,
   topology-aware-lifecycle-manager.v4.18.5, packageserver,
   cephcsi-operator.v4.18.25-rhodf, mcg-operator.v4.18.25-rhodf,
   ocs-client-operator.v4.18.25-rhodf, odf-csi-addons-operator.v4.18.25-rhodf,
   odf-dependencies.v4.18.25-rhodf, odf-operator.v4.18.25-rhodf,
   odf-prometheus-operator.v4.18.25-rhodf, recipe.v4.18.25-rhodf,
   rook-ceph-operator.v4.18.25-rhodf, ...
[must-gather      ] OUT 2026-07-31T08:34:48.344978555Z Using must-gather plug-in image:
   quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d...,
   registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900...,
   registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb...,
   registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752...,
   registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:51e0bbde...,
   registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:f12f016d...
When opening a support case, bugzilla, or issue please include the following summary data
along with any other requested information:
ClusterID: 6bb33e72-07a1-4284-ab9f-05516d469689
ClientVersion: unknown
ClusterVersion: Stable at "4.18.27"
ClusterOperators:
  All healthy and stable


[must-gather      ] OUT 2026-07-31T08:34:48.811666519Z namespace/openshift-must-gather-g74xh created
[must-gather      ] OUT 2026-07-31T08:34:48.959852123Z clusterrolebinding.rbac.authorization.k8s.io/must-gather-qkk4f created
[must-gather      ] OUT 2026-07-31T08:34:49.259808718Z pod for plug-in image
   registry.redhat.io/oadp/oadp-mustgather-rhel9@sha256:87000900... created
[must-gather      ] OUT 2026-07-31T08:34:49.268102002Z pod for plug-in image
   registry.redhat.io/openshift-logging/cluster-logging-rhel9-operator@sha256:534f2752... created
[must-gather      ] OUT 2026-07-31T08:34:49.268135525Z pod for plug-in image
   quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:a2c8408d... created
[must-gather      ] OUT 2026-07-31T08:34:49.268271219Z pod for plug-in image
   registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:ea72befb... created

Key Differences

Aspect Before After
ClusterOperator missing-annotation warning Not emitted Emitted before image list
CSV missing-annotation warning Not emitted Emitted before image list
Using must-gather plug-in image line First output line Third output line
Logging format [must-gather] OUT <timestamp> <message> Same format, consistent
Image selection Unchanged Unchanged
Pod creation Unchanged Unchanged

How to Reproduce

make oc   # or: go build -mod=vendor -tags 'include_gcs include_oss containers_image_openpgp' -o ./oc ./cmd/oc/
export KUBECONFIG=./kubeconfig
bash ./test_must_gather_annotation_warning.sh

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.

@ardaguclu

Copy link
Copy Markdown
Member

/hold

@openshift-ci openshift-ci Bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 31, 2026
@ardaguclu

Copy link
Copy Markdown
Member

/lgtm cancel
we first need to ensure that we don't flood the logs

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

openshift-ci Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: midu16
Once this PR has been reviewed and has the lgtm label, please ask for approval from ardaguclu. 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

@openshift-ci openshift-ci Bot removed the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 31, 2026
@ardaguclu

Copy link
Copy Markdown
Member

/approve cancel

ClusterOperators are platform-level components that never carry the
must-gather-image annotation—listing all 34 of them on every
--all-images run is noise. Remove the CO warning entirely and keep
the annotation check only for day-2 operators (CSVs).

CSVs exist in every namespace, producing 100+ duplicated entries in
the warning line. Use a map[string]struct{} set to deduplicate names
and slices.Sorted(maps.Keys(...)) for deterministic, sorted output.
@openshift-ci-robot openshift-ci-robot removed the verified Signifies that the PR passed pre-merge verification criteria label Jul 31, 2026
@midu16

midu16 commented Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

@ardaguclu the new change:

`midu@midu-thinkpadp16vgen1:~/oc$ ./oc adm must-gather --all-images
[must-gather ] OUT 2026-07-31T14:19:59.509617907Z CSVs without operators.openshift.io/must-gather-image annotation: cephcsi-operator.v4.21.9-rhodf, mcg-operator.v4.21.9-rhodf, oadp-operator.v1.6.1, ocs-client-operator.v4.21.9-rhodf, odf-csi-addons-operator.v4.21.9-rhodf, odf-dependencies.v4.21.9-rhodf, odf-external-snapshotter-operator.v4.21.9-rhodf, odf-operator.v4.21.9-rhodf, odf-prometheus-operator.v4.21.9-rhodf, packageserver, quay-operator.v3.16.5, recipe.v4.21.9-rhodf, rook-ceph-operator.v4.21.9-rhodf, topology-aware-lifecycle-manager.v4.22.0
[must-gather ] OUT 2026-07-31T14:19:59.509637554Z Using must-gather plug-in image: quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:247045b6df3e9f7ccc796c6df492be3fa1df4937c284fbb5a08a6614af0f93e1, registry.redhat.io/openshift4/ose-local-storage-mustgather-rhel9@sha256:8123969ba984e8ca09649e144bcde15187107347d6562adde4a20cec6092944c, registry.redhat.io/odf4/odf-must-gather-rhel9@sha256:009aa228f54b26c3b4808d8609bb365eb73e050e56a2d713d46c4c8bb94bb45d, registry.redhat.io/openshift-gitops-1/must-gather-rhel9@sha256:36cfce9298bee2a7c81e8b120a6cc28f3e5e2f4656abc9cf6aa7a5e377b6249a, registry.redhat.io/multicluster-engine/must-gather-rhel9@sha256:e5db11243d9db5c27989c6da46ed473b6b7ff19ad903e9d759c20db82169b40c, registry.redhat.io/rhacm2/acm-must-gather-rhel9@sha256:1a4f21543e04c163a27ffba289dcab16464b014c20a625189c8e878c8534467d
When opening a support case, bugzilla, or issue please include the following summary data along with any other requested information:
ClusterID: 69b6e1de-49e8-405c-ba5c-f8aeb5069d85
ClientVersion: unknown
ClusterVersion: Stable at "4.22.5"
ClusterOperators:
clusteroperator/operator-lifecycle-manager is not upgradeable because ClusterServiceVersions blocking minor version upgrades to 4.23 or major version upgrades to 5.0:

  • maximum supported OCP version for openshift-storage/odf-operator.v4.21.9-rhodf is 4.22
  • maximum supported OCP version for openshift-storage/odf-dependencies.v4.21.9-rhodf is 4.22

[must-gather ] OUT 2026-07-31T14:19:59.92175445Z namespace/openshift-must-gather-dmn8f created
[must-gather ] OUT 2026-07-31T14:20:00.057629817Z clusterrolebinding.rbac.authorization.k8s.io/must-gather-twzrk created
[must-gather ] OUT 2026-07-31T14:20:00.445839017Z pod for plug-in image quay.io/openshift-release-dev/ocp-v4.0-art-dev@sha256:247045b6df3e9f7ccc796c6df492be3fa1df4937c284fbb5a08a6614af0f93e1 created
`

Comment thread pkg/cli/admin/mustgather/mustgather.go Outdated
Replace map[string]struct{} with k8s.io/apimachinery/pkg/util/sets.Set
for deduplicating CSV names missing the must-gather-image annotation.
sets.List() returns a sorted slice, replacing slices.Sorted(maps.Keys()).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants