Skip to content

MCO-2468: Cache backed OSImageStreams for PIS - #6329

Open
pablintino wants to merge 1 commit into
openshift:mainfrom
pablintino:mco-2468
Open

MCO-2468: Cache backed OSImageStreams for PIS#6329
pablintino wants to merge 1 commit into
openshift:mainfrom
pablintino:mco-2468

Conversation

@pablintino

@pablintino pablintino commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

- What I did

This change leverages the recently added inspection cache to allow disconnected environments using PIS to be able to discover streams.

- How to verify it

TBD

- Description for the changelog

This change leverages the recently added inspection cache to allow disconnected environments using PIS to be able to discover streams.

Summary by CodeRabbit

  • New Features
    • Optionally warms the inspection cache for images referenced by pinned image sets when stream caching is enabled.
    • Adds a background cache warmer that preloads release payload manifest references.
    • Cache warming is triggered on pinned image set create and update events.
  • Enhancements
    • Release payload images are detected via a dedicated helper for consistent identification.
  • Testing
    • Added coverage to verify cache warming reacts to pinned image set changes.
  • Chores
    • Standardized OS image inspection context timeout to a shared 5-minute value.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.

This repository is configured in: LGTM mode

@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 23, 2026
@openshift-ci-robot

openshift-ci-robot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@pablintino: This pull request references MCO-2468 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 "5.0.0" version, but no target version was set.

Details

In response to this:

- What I did

This change leverages the recently added inspection cache to allow disconnected environments using PIS to be able to discover streams.

- How to verify it

TBD

- Description for the changelog

This change leverages the recently added inspection cache to allow disconnected environments using PIS to be able to discover streams.

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 23, 2026

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

The PR adds asynchronous inspection-cache warming for images referenced by PinnedImageSet resources, including release payload manifests. It wires the warmer into controller startup and PinnedImageSet events, adds release-payload detection, and centralizes the image inspection timeout.

Changes

Pinned image cache warming

Layer / File(s) Summary
Inspection contracts and timeout
pkg/osimagestream/image_data.go, pkg/osimagestream/osimagestream.go, pkg/controller/osimagestream/osimagestream_controller.go
Adds release-payload detection and uses a shared five-minute image inspection timeout.
Cache warmer execution
pkg/controller/pinnedimageset/cache_warmer.go
Lists and deduplicates pinned images, warms inspection data, fetches release manifests, retains referenced digests, and coalesces warm requests.
Controller wiring and validation
pkg/controller/pinnedimageset/pinned_image_set.go, cmd/machine-config-controller/start.go, pkg/controller/pinnedimageset/*_test.go
Starts and triggers the optional warmer, wires its dependencies when inspection caching is enabled, and tests PinnedImageSet create/update warming.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant PinnedImageSetController
  participant CacheWarmer
  participant PinnedImageSetLister
  participant ImagesInspector
  participant InspectionCache
  PinnedImageSetController->>CacheWarmer: Request warm
  CacheWarmer->>PinnedImageSetLister: List PinnedImageSets
  CacheWarmer->>ImagesInspector: Inspect unique pinned images
  CacheWarmer->>ImagesInspector: Fetch release manifest
  ImagesInspector->>InspectionCache: Populate inspection entries
Loading

Suggested reviewers: sergiordlr, dkhater-redhat


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 cache_warmer.go logs r.Image on fetch failures; r.Image comes from PinnedImageSet pullspecs and can expose registry hostnames. Redact the image reference in the warning or log only the digest/hashed ID; avoid emitting full pullspecs in failure logs.
Docstring Coverage ⚠️ Warning Docstring coverage is 60.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 is concise and accurately summarizes the main change: adding cache-backed OSImageStreams support for PIS.
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 No Ginkgo titles were added; the changed tests use static t.Run names like "happy path" and no dynamic values.
Test Structure And Quality ✅ Passed PASS: The new test is self-contained, uses temp-dir/context cleanup, has bounded Eventually timeouts, and matches existing fake-client/informer patterns.
Microshift Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the only new test is a unit test with fake clients/informers, so MicroShift API compatibility isn't implicated.
Single Node Openshift (Sno) Test Compatibility ✅ Passed No new Ginkgo/e2e tests were added; the new test is a Go unit test using testing, with no multi-node/HA assumptions or SNO-specific skips needed.
Topology-Aware Scheduling Compatibility ✅ Passed PASS: Diff only adds cache-warming/controller wiring; searches found no nodeSelector, affinity, tolerations, spread constraints, replicas, or control-plane targeting.
Ote Binary Stdout Contract ✅ Passed PASS: The changed files contain no stdout prints in init/main/setup; runStartCmd sets logtostderr=true before klog logging, and the new test code has no suite-level output.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No new Ginkgo e2e tests were added; the new test is a unit test using fakes and no external connectivity.
No-Weak-Crypto ✅ Passed No MD5/SHA1/DES/RC4/3DES/Blowfish/ECB, custom crypto, or secret/token comparisons were introduced; only sha256 digests in test fixtures and ordinary object compares.
Container-Privileges ✅ Passed Touched files are Go controller/cache code only; no K8s manifests or securityContext fields like privileged/hostNetwork/allowPrivilegeEscalation were added.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci

openshift-ci Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pablintino

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 23, 2026

@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 (1)
pkg/controller/pinnedimageset/cache_warmer.go (1)

118-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider logging inspection errors, not just fetch errors.

r.Error != nil is silently skipped; only FetchImageFile failures are logged (Line 125-127). Logging inspection failures too would help diagnose why warming silently fails to warm a given image.

📝 Proposed fix
 	for _, r := range results {
-		if r.Error != nil || r.InspectInfo == nil || !osimagestream.IsReleasePayload(r.InspectInfo.Labels) {
+		if r.Error != nil {
+			klog.Warningf("PIS cache warmer: failed to inspect %s: %v", r.Image, r.Error)
+			continue
+		}
+		if r.InspectInfo == nil || !osimagestream.IsReleasePayload(r.InspectInfo.Labels) {
 			continue
 		}
🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go` around lines 118 - 121, Update
the results loop in the cache-warming flow to log each non-nil r.Error before
continuing, alongside the existing FetchImageFile failure logging. Include
enough context to identify the affected image, while preserving the current
skips for missing InspectInfo and non-release payloads.
🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go`:
- Around line 96-131: Update CacheWarmer.Warm to derive a per-cycle timeout
context from ctx before calling inspector.Inspect and inspector.FetchImageFile.
Use the configured or established warm-cycle timeout symbol, defer its
cancellation, and pass the derived context to both registry calls so each Warm
invocation is bounded while preserving the existing error handling and shutdown
cancellation.

---

Nitpick comments:
In `@pkg/controller/pinnedimageset/cache_warmer.go`:
- Around line 118-121: Update the results loop in the cache-warming flow to log
each non-nil r.Error before continuing, alongside the existing FetchImageFile
failure logging. Include enough context to identify the affected image, while
preserving the current skips for missing InspectInfo and non-release payloads.
🪄 Autofix (Beta)

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

Review profile: CHILL

Plan: Enterprise

Run ID: efb19ced-6a2c-47a8-b014-41a4ea05e459

📥 Commits

Reviewing files that changed from the base of the PR and between 6197659 and b02856f.

📒 Files selected for processing (6)
  • cmd/machine-config-controller/start.go
  • pkg/controller/pinnedimageset/cache_warmer.go
  • pkg/controller/pinnedimageset/cache_warmer_test.go
  • pkg/controller/pinnedimageset/pinned_image_set.go
  • pkg/controller/pinnedimageset/pinned_image_set_test.go
  • pkg/osimagestream/image_data.go

Comment thread pkg/controller/pinnedimageset/cache_warmer.go
@pablintino

Copy link
Copy Markdown
Contributor Author

/pipeline required

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

Scheduling tests matching the pipeline_run_if_changed or not excluded by pipeline_skip_if_only_changed parameters:
/test e2e-aws-ovn
/test e2e-aws-ovn-upgrade
/test e2e-gcp-op-ocl-part1
/test e2e-gcp-op-ocl-part2
/test e2e-gcp-op-part1
/test e2e-gcp-op-part2
/test e2e-gcp-op-single-node
/test e2e-hypershift

@pablintino

Copy link
Copy Markdown
Contributor Author

/test unit

@isabella-janssen

Copy link
Copy Markdown
Member

/hold

Holding to allow the Kube rebase to land in #6321. Please ensure this will not cause merge conflicts for the Kube rebase before unholding this PR.

@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 28, 2026
@pablintino
pablintino force-pushed the mco-2468 branch 2 times, most recently from 93da1b1 to 6bf59cd Compare July 29, 2026 08:57
This change leverages the recently added inspection cache to allow
disconnected environments using PIS to be able to discover streams.

Signed-off-by: Pablo Rodriguez Nava <git@amail.pablintino.eu>

@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

🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go`:
- Line 122: Update the failure log in the cache warmer’s image-reference fetch
path to omit both r.Image and the raw err, emitting only a sanitized generic
failure signal. Preserve the existing warning level and failure handling while
ensuring no private registry hostname or error details are logged.
🪄 Autofix (Beta)

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

Review profile: CHILL

Plan: Enterprise

Run ID: ef98f440-bea2-4d9b-b3ec-ccd74058b09c

📥 Commits

Reviewing files that changed from the base of the PR and between 93da1b1 and 6bf59cd.

📒 Files selected for processing (8)
  • cmd/machine-config-controller/start.go
  • pkg/controller/osimagestream/osimagestream_controller.go
  • pkg/controller/pinnedimageset/cache_warmer.go
  • pkg/controller/pinnedimageset/cache_warmer_test.go
  • pkg/controller/pinnedimageset/pinned_image_set.go
  • pkg/controller/pinnedimageset/pinned_image_set_test.go
  • pkg/osimagestream/image_data.go
  • pkg/osimagestream/osimagestream.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/osimagestream/image_data.go
  • pkg/osimagestream/osimagestream.go
  • pkg/controller/osimagestream/osimagestream_controller.go
  • pkg/controller/pinnedimageset/cache_warmer_test.go
  • cmd/machine-config-controller/start.go
  • pkg/controller/pinnedimageset/pinned_image_set_test.go
  • pkg/controller/pinnedimageset/pinned_image_set.go

// path. Fetching it here warms the file in the inspection cache so that
// later consumers (e.g. the osimagestream controller) get a cache hit.
if _, err := inspector.FetchImageFile(ctx, r.Image, releaseImageStreamPath); err != nil {
klog.Warningf("PIS cache warmer: failed to fetch image-references from %s: %v", r.Image, err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not log the raw image reference or registry error.

r.Image can expose customer/private registry hostnames, and the error may include the same reference. Log a sanitized failure signal instead.

Proposed fix
-			klog.Warningf("PIS cache warmer: failed to fetch image-references from %s: %v", r.Image, err)
+			klog.Warning("PIS cache warmer: failed to fetch image-references")

As per coding guidelines, “Flag logging that may expose passwords, tokens, API keys, PII (email, SSN, credit card), session IDs, internal hostnames, or customer data.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
klog.Warningf("PIS cache warmer: failed to fetch image-references from %s: %v", r.Image, err)
klog.Warning("PIS cache warmer: failed to fetch image-references")
🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go` at line 122, Update the
failure log in the cache warmer’s image-reference fetch path to omit both
r.Image and the raw err, emitting only a sanitized generic failure signal.
Preserve the existing warning level and failure handling while ensuring no
private registry hostname or error details are logged.

Source: Coding guidelines

@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

🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go`:
- Line 74: The cache-warming warning in the relevant cache-warming function
currently logs raw inspection errors that may expose sensitive image or registry
details. Replace the err-inclusive klog.Warningf call with a sanitized warning
message that conveys the cache-warming failure without error contents,
preserving the existing warning behavior.
🪄 Autofix (Beta)

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

Review profile: CHILL

Plan: Enterprise

Run ID: b3b22da3-f130-4549-8740-b31edf1f6221

📥 Commits

Reviewing files that changed from the base of the PR and between 6bf59cd and 58a9a52.

📒 Files selected for processing (8)
  • cmd/machine-config-controller/start.go
  • pkg/controller/osimagestream/osimagestream_controller.go
  • pkg/controller/pinnedimageset/cache_warmer.go
  • pkg/controller/pinnedimageset/cache_warmer_test.go
  • pkg/controller/pinnedimageset/pinned_image_set.go
  • pkg/controller/pinnedimageset/pinned_image_set_test.go
  • pkg/osimagestream/image_data.go
  • pkg/osimagestream/osimagestream.go
🚧 Files skipped from review as they are similar to previous changes (7)
  • pkg/osimagestream/osimagestream.go
  • pkg/controller/pinnedimageset/pinned_image_set_test.go
  • pkg/controller/osimagestream/osimagestream_controller.go
  • pkg/osimagestream/image_data.go
  • pkg/controller/pinnedimageset/pinned_image_set.go
  • pkg/controller/pinnedimageset/cache_warmer_test.go
  • cmd/machine-config-controller/start.go

select {
case <-w.signal:
if err := w.Warm(ctx); err != nil {
klog.Warningf("PinnedImageSet cache warming failed: %v", err)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not log raw inspection errors.

err can include PIS image references or private registry hostnames. Emit a sanitized warning instead.

Proposed fix
-				klog.Warningf("PinnedImageSet cache warming failed: %v", err)
+				klog.Warning("PinnedImageSet cache warming failed")

As per coding guidelines, “Flag logging that may expose passwords, tokens, API keys, PII (email, SSN, credit card), session IDs, internal hostnames, or customer data.”

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
klog.Warningf("PinnedImageSet cache warming failed: %v", err)
klog.Warning("PinnedImageSet cache warming failed")
🤖 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 `@pkg/controller/pinnedimageset/cache_warmer.go` at line 74, The cache-warming
warning in the relevant cache-warming function currently logs raw inspection
errors that may expose sensitive image or registry details. Replace the
err-inclusive klog.Warningf call with a sanitized warning message that conveys
the cache-warming failure without error contents, preserving the existing
warning behavior.

Source: Coding guidelines

@openshift-ci

openshift-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

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

@isabella-janssen

Copy link
Copy Markdown
Member

/unhold

Kube rebase landed

@openshift-ci openshift-ci Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 29, 2026
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.

3 participants