MCO-2468: Cache backed OSImageStreams for PIS - #6329
Conversation
|
Pipeline controller notification For optional jobs, comment This repository is configured in: LGTM mode |
|
@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. DetailsIn response to this:
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. |
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThe PR adds asynchronous inspection-cache warming for images referenced by ChangesPinned image cache 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
Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error, 1 warning)
✅ Passed checks (13 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/controller/pinnedimageset/cache_warmer.go (1)
118-121: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider logging inspection errors, not just fetch errors.
r.Error != nilis silently skipped; onlyFetchImageFilefailures 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
📒 Files selected for processing (6)
cmd/machine-config-controller/start.gopkg/controller/pinnedimageset/cache_warmer.gopkg/controller/pinnedimageset/cache_warmer_test.gopkg/controller/pinnedimageset/pinned_image_set.gopkg/controller/pinnedimageset/pinned_image_set_test.gopkg/osimagestream/image_data.go
|
/pipeline required |
|
Scheduling tests matching the |
|
/test unit |
|
/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. |
93da1b1 to
6bf59cd
Compare
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>
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
cmd/machine-config-controller/start.gopkg/controller/osimagestream/osimagestream_controller.gopkg/controller/pinnedimageset/cache_warmer.gopkg/controller/pinnedimageset/cache_warmer_test.gopkg/controller/pinnedimageset/pinned_image_set.gopkg/controller/pinnedimageset/pinned_image_set_test.gopkg/osimagestream/image_data.gopkg/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) |
There was a problem hiding this comment.
🔒 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.
| 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
There was a problem hiding this comment.
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
📒 Files selected for processing (8)
cmd/machine-config-controller/start.gopkg/controller/osimagestream/osimagestream_controller.gopkg/controller/pinnedimageset/cache_warmer.gopkg/controller/pinnedimageset/cache_warmer_test.gopkg/controller/pinnedimageset/pinned_image_set.gopkg/controller/pinnedimageset/pinned_image_set_test.gopkg/osimagestream/image_data.gopkg/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) |
There was a problem hiding this comment.
🔒 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.
| 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
|
@pablintino: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. |
|
/unhold Kube rebase landed |
- 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