From dbffbe8f9bbeb784a5ebbd8979e548370548b6e8 Mon Sep 17 00:00:00 2001 From: Tibor Vass Date: Mon, 16 Nov 2020 17:16:06 +0000 Subject: [PATCH] builder-next: fix platform-specific behavior Signed-off-by: Tibor Vass --- builder/builder-next/adapters/containerimage/pull.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/builder/builder-next/adapters/containerimage/pull.go b/builder/builder-next/adapters/containerimage/pull.go index d0891cb598..733a337e87 100644 --- a/builder/builder-next/adapters/containerimage/pull.go +++ b/builder/builder-next/adapters/containerimage/pull.go @@ -93,7 +93,13 @@ func (is *Source) resolveRemote(ctx context.Context, ref string, platform *ocisp dgst digest.Digest dt []byte } - res, err := is.g.Do(ctx, ref, func(ctx context.Context) (interface{}, error) { + p := platforms.DefaultSpec() + if platform != nil { + p = *platform + } + // key is used to synchronize resolutions that can happen in parallel when doing multi-stage. + key := "getconfig::" + ref + "::" + platforms.Format(p) + res, err := is.g.Do(ctx, key, func(ctx context.Context) (interface{}, error) { res := resolver.DefaultPool.GetResolver(is.RegistryHosts, ref, "pull", sm, g) dgst, dt, err := imageutil.Config(ctx, ref, res, is.ContentStore, nil, platform) if err != nil { @@ -247,7 +253,9 @@ func (p *puller) resolveLocal() { } func (p *puller) resolve(ctx context.Context, g session.Group) error { - _, err := p.is.g.Do(ctx, "", func(ctx context.Context) (_ interface{}, err error) { + // key is used to synchronize resolutions that can happen in parallel when doing multi-stage. + key := "resolve::" + p.ref + "::" + platforms.Format(p.platform) + _, err := p.is.g.Do(ctx, key, func(ctx context.Context) (_ interface{}, err error) { resolveProgressDone := oneOffProgress(ctx, "resolve "+p.src.Reference.String()) defer func() { resolveProgressDone(err)