Memoize image digest resolution across a WithImagesResolved call - #899
Merged
glours merged 1 commit intoJul 21, 2026
Merged
Conversation
WithImagesResolved deduplicates concurrent resolutions of the same image via singleflight, but singleflight forgets a key as soon as its call returns, so images resolved sequentially — a pre_start hook or a `type: image` volume source equal to service.Image, resolved one after another within a single service transform — still triggered a duplicate registry round-trip. Back singleflight with a sync.Map memoizing results for the whole call so each distinct image reference is resolved exactly once, whether the repeat lookups are concurrent or sequential. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
glours
approved these changes
Jul 21, 2026
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.
Follow-up to #894.
WithImagesResolveduses asingleflight.Groupto collapse concurrent resolutions of the same image, but singleflight forgets a key as soon as its call returns. Images resolved sequentially — apre_starthook or atype: imagevolume source equal toservice.Image, resolved one after another within a single service transform — therefore still hit the resolver twice.This backs singleflight with a
sync.Mapmemoizing results for the whole call, so each distinct image reference is resolved exactly once whether the repeat lookups are concurrent or sequential. singleflight still guards the concurrent burst before it reaches the cache.