Repository navigation
Conversation
oci.New maintains index.json, which is not safe to share between concurrent processes, so two oras invocations using the same ORAS_CACHE could corrupt it. oci.NewStorage does not maintain index.json and is process-safe, as oras-go's own cache package uses it. Signed-off-by: Ogulcan Aydogan <[email protected]>
ogulcanaydogan
requested review from
TerryHowe,
Wwwsylvia,
sabre1041,
sajayantony and
shizhMSFT
as code owners
November 10, 2026 18:35
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2329 +/- ##
=======================================
Coverage 73.51% 73.51%
=======================================
Files 157 157
Lines 6582 6582
=======================================
Hits 4839 4839
Misses 1454 1454
Partials 289 289 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
|
Thanks! |
2 of 4 tasks
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2312
CachedTargetbacked theORAS_CACHEstore withoci.New(), which maintainsindex.jsonand is not safe for concurrent writes from several processes. It now usesoci.NewStorage(), which has noindex.json, as oras-go'scontent/cachedoes. The call site is the only change incache.go:internal/cachetakes acontent.Storage, whichoci.Storagesatisfies, so nothing downstream relies on the tag or index behaviour ofoci.Store.Tests:
TestCache_CachedTargetnow also checks that noindex.jsonis created in the cache root.TestCache_CachedTarget_sharedRootruns 8 goroutines that each cache a different blob in the same root, and checks the content and that noindex.jsonappears.Both fail with
oci.New()(index.jsonexists) and pass with this change, andgo test -race ./cmd/oras/...and golangci-lint are clean. I can't reproduce the cross-process corruption deterministically, so the tests check that the file that makes it possible is no longer maintained. This is the first part of #2313, which would still move tocontent/cache