Skip to content

Commit

Permalink
Don't AppendDescriptor until we've written config (#1175)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jonjohnsonjr authored Nov 6, 2023
1 parent 1f21846 commit 93d195e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/commands/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 93d195e

Please sign in to comment.