From 6e28c0505fc4791ca65ba12c3a7e1ae5a8eccc73 Mon Sep 17 00:00:00 2001 From: Joel Longtine Date: Thu, 6 Jan 2022 15:34:19 -0700 Subject: [PATCH 1/2] Force another solve, so that the LLB created by the dockerfile.v0 frontend actually runs, as we expect it to. Also, enforce Evaluate: true on SolveRequests that run through the Solver Signed-off-by: Joel Longtine --- plan/task/build.go | 14 +++++++++++++- solver/solver.go | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plan/task/build.go b/plan/task/build.go index 31b5f127..d65df05e 100644 --- a/plan/task/build.go +++ b/plan/task/build.go @@ -115,6 +115,18 @@ func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s return nil, err } + st, err := ref.ToState() + + if err != nil { + return nil, err + } + + solvedRef, err := s.Solve(ctx, st, pctx.Platform.Get()) + + if err != nil { + return nil, err + } + // Image metadata meta, ok := res.Metadata[exptypes.ExporterImageConfigKey] if !ok { @@ -126,7 +138,7 @@ func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s } return compiler.NewValue().FillFields(map[string]interface{}{ - "output": pctx.FS.New(ref).MarshalCUE(), + "output": pctx.FS.New(solvedRef).MarshalCUE(), "config": image.Config, }) } diff --git a/solver/solver.go b/solver/solver.go index 01db431f..23451c32 100644 --- a/solver/solver.go +++ b/solver/solver.go @@ -120,6 +120,7 @@ func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.Res // Solve will block until the state is solved and returns a Reference. func (s Solver) SolveRequest(ctx context.Context, req bkgw.SolveRequest) (*bkgw.Result, error) { + req.Evaluate = true res, err := s.opts.Gateway.Solve(ctx, req) if err != nil { return nil, CleanError(err) From e6bbc5bf01e99298b6f7fbea7efe8971c23da899 Mon Sep 17 00:00:00 2001 From: Joel Longtine Date: Thu, 6 Jan 2022 19:40:38 -0700 Subject: [PATCH 2/2] Fix nits + comments Signed-off-by: Joel Longtine --- plan/task/build.go | 2 -- solver/solver.go | 8 +++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/plan/task/build.go b/plan/task/build.go index d65df05e..503c6d5f 100644 --- a/plan/task/build.go +++ b/plan/task/build.go @@ -116,13 +116,11 @@ func (t *buildTask) dockerfile(ctx context.Context, pctx *plancontext.Context, s } st, err := ref.ToState() - if err != nil { return nil, err } solvedRef, err := s.Solve(ctx, st, pctx.Platform.Get()) - if err != nil { return nil, err } diff --git a/solver/solver.go b/solver/solver.go index 23451c32..f1d85187 100644 --- a/solver/solver.go +++ b/solver/solver.go @@ -120,6 +120,9 @@ func (s Solver) ResolveImageConfig(ctx context.Context, ref string, opts llb.Res // Solve will block until the state is solved and returns a Reference. func (s Solver) SolveRequest(ctx context.Context, req bkgw.SolveRequest) (*bkgw.Result, error) { + // makes Solve() to block until LLB graph is solved. otherwise it will + // return result (that you can for example use for next build) that + // will be evaluated on export or if you access files on it. req.Evaluate = true res, err := s.opts.Gateway.Solve(ctx, req) if err != nil { @@ -150,11 +153,6 @@ func (s Solver) Solve(ctx context.Context, st llb.State, platform specs.Platform // call solve res, err := s.SolveRequest(ctx, bkgw.SolveRequest{ Definition: def, - - // makes Solve() to block until LLB graph is solved. otherwise it will - // return result (that you can for example use for next build) that - // will be evaluated on export or if you access files on it. - Evaluate: true, }) if err != nil { return nil, err