Make OCI image layer cache safe for concurrent use#3150
Make OCI image layer cache safe for concurrent use#3150robnester-rh wants to merge 2 commits intoconforma:mainfrom
Conversation
Review Summary by QodoMake OCI image layer cache safe for concurrent use
WalkthroughsDescription• Wrap OCI image layer cache with thread-safe singleflight serialization • Prevents race conditions when multiple goroutines validate shared layers • Add comprehensive unit tests for concurrent cache access patterns • Add acceptance test validating parallel image validation with cache Diagramflowchart LR
A["FilesystemCache"] -->|wrapped by| B["SafeCache"]
B -->|serializes Put| C["singleflight.Group"]
B -->|wraps Layer| D["SafeLayer"]
D -->|serializes Compressed/Uncompressed| C
E["Multiple Goroutines"] -->|concurrent access| B
B -->|prevents races| F["Shared Layer Cache"]
File Changes1. internal/utils/oci/client.go
|
Code Review by Qodo
1. require in goroutines
|
f1b01de to
5be317b
Compare
Wrap go-containerregistry's FilesystemCache in a thread-safe wrapper that uses singleflight to serialize Put and layer stream reads. Prevents races when multiple goroutines validate the same image (e.g. parallel components sharing layers). Add unit tests for the safe cache and an acceptance scenario that runs validation with EC_CACHE=true. Ref: conforma#1109 Ref: EC-1669 Co-authored-by: Claude Code <noreply@anthropic.com> Signed-off-by: Rob Nester <rnester@redhat.com>
|
/review |
PR Reviewer Guide 🔍(Review updated until commit 37c6631)Here are some key observations to aid the review process:
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Use digest- and diffID-scoped singleflight inside Compressed() and Uncompressed() so only one goroutine runs the inner stream per digest across all safeLayer instances (e.g. concurrent Get(digest) callers). Waiters no longer depend on the first caller closing a reader, avoiding deadlock. Remove per-layer ready channels and streamingCloseReader. Add unit tests for error paths, cache-hit paths, and concurrent Get callers calling Compressed(); add a short comment in the acceptance scenario for the parallel-validation-with-cache step. Ref: conforma#1109 Ref: EC-1669 Co-authored-by: Claude Code <noreply@anthropic.com> Signed-off-by: Rob Nester <rnester@redhat.com>
|
/review |
|
Persistent review updated to latest commit 37c6631 |
Wrap go-containerregistry's FilesystemCache in a thread-safe wrapper that uses singleflight to serialize Put and layer stream reads. Prevents races when multiple goroutines validate the same image (e.g. parallel components sharing layers).
Add unit tests for the safe cache and an acceptance scenario that runs validation with EC_CACHE=true.
Ref: #1109
Ref: EC-1669