summaryrefslogtreecommitdiff
path: root/builder
diff options
context:
space:
mode:
authorTibor Vass <tibor@docker.com>2020-11-13 03:46:53 +0000
committerTibor Vass <tibor@docker.com>2020-11-14 03:57:36 +0000
commit8f464ae2ab8275a1c29984b501cc083a5973efe0 (patch)
tree83d9ac1f7b377fdcdd8cbeeef56e5fe8af78e6b4 /builder
parent1b1eb094cc5802ced2a8d993880992b3daf800bd (diff)
downloaddocker-8f464ae2ab8275a1c29984b501cc083a5973efe0.tar.gz
builder-next: refactor to use flighcontrol and remove resolveOnce
Signed-off-by: Tibor Vass <tibor@docker.com>
Diffstat (limited to 'builder')
-rw-r--r--builder/builder-next/adapters/containerimage/pull.go27
1 files changed, 10 insertions, 17 deletions
diff --git a/builder/builder-next/adapters/containerimage/pull.go b/builder/builder-next/adapters/containerimage/pull.go
index 29321db80b..d0891cb598 100644
--- a/builder/builder-next/adapters/containerimage/pull.go
+++ b/builder/builder-next/adapters/containerimage/pull.go
@@ -176,12 +176,10 @@ func (is *Source) Resolve(ctx context.Context, id source.Identifier, sm *session
type puller struct {
is *Source
- resolveOnce sync.Once
resolveLocalOnce sync.Once
src *source.ImageIdentifier
desc ocispec.Descriptor
ref string
- resolveErr error
config []byte
platform ocispec.Platform
sm *session.Manager
@@ -249,22 +247,21 @@ func (p *puller) resolveLocal() {
}
func (p *puller) resolve(ctx context.Context, g session.Group) error {
- p.resolveOnce.Do(func() {
+ _, err := p.is.g.Do(ctx, "", func(ctx context.Context) (_ interface{}, err error) {
resolveProgressDone := oneOffProgress(ctx, "resolve "+p.src.Reference.String())
+ defer func() {
+ resolveProgressDone(err)
+ }()
ref, err := distreference.ParseNormalizedNamed(p.src.Reference.String())
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
if p.desc.Digest == "" && p.config == nil {
origRef, desc, err := p.resolver(g).Resolve(ctx, ref.String())
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
p.desc = desc
@@ -279,22 +276,18 @@ func (p *puller) resolve(ctx context.Context, g session.Group) error {
if p.config == nil && p.desc.MediaType != images.MediaTypeDockerSchema1Manifest {
ref, err := distreference.WithDigest(ref, p.desc.Digest)
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
_, dt, err := p.is.ResolveImageConfig(ctx, ref.String(), llb.ResolveImageConfigOpt{Platform: &p.platform, ResolveMode: resolveModeToString(p.src.ResolveMode)}, p.sm, g)
if err != nil {
- p.resolveErr = err
- _ = resolveProgressDone(err)
- return
+ return nil, err
}
p.config = dt
}
- _ = resolveProgressDone(nil)
+ return nil, nil
})
- return p.resolveErr
+ return err
}
func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (string, solver.CacheOpts, bool, error) {