From 93d195ee35bada786c9218a179341f0c2c79a630 Mon Sep 17 00:00:00 2001 From: Jon Johnson Date: Mon, 6 Nov 2023 09:28:13 -0800 Subject: [PATCH] Don't AppendDescriptor until we've written config (#1175) I have a suspicion that this is causing a race where we modify the cache's index.json file before we actually write out the image's config file, so if we call RawConfigFile before we finish caching it, we'll just fail to find that file. Signed-off-by: Jon Johnson --- pkg/commands/cache.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/commands/cache.go b/pkg/commands/cache.go index 9f235abefc..5ce5b74cda 100644 --- a/pkg/commands/cache.go +++ b/pkg/commands/cache.go @@ -165,10 +165,6 @@ func (i *imageCache) get(ctx context.Context, ref name.Reference, missFunc baseF return result, err } - if err := i.p.AppendDescriptor(*desc); err != nil { - return result, err - } - if _, ok := result.(v1.ImageIndex); ok { result = &lazyIndex{ ref: ref, @@ -202,6 +198,10 @@ func (i *imageCache) get(ctx context.Context, ref name.Reference, missFunc baseF cache: i, } } + + if err := i.p.AppendDescriptor(*desc); err != nil { + return result, err + } } i.cache.Store(ref.String(), result)