Skip to content

Commit

Permalink
fileop: create new fileOpSolver instance per Exec call
Browse files Browse the repository at this point in the history
FileOpSolver keeps internal state about the vertex that
has been loaded into it and should not be reused.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit e7caa2e)
  • Loading branch information
tonistiigi committed Apr 3, 2023
1 parent 08941b1 commit a1ae2bd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions solver/llbsolver/ops/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ const fileCacheType = "buildkit.file.v0"

type fileOp struct {
op *pb.FileOp
md cache.MetadataStore
w worker.Worker
solver *FileOpSolver
refManager *file.RefManager
numInputs int
parallelism *semaphore.Weighted
}
Expand All @@ -41,12 +40,12 @@ func NewFileOp(v solver.Vertex, op *pb.Op_File, cm cache.Manager, parallelism *s
if err := opsutils.Validate(&pb.Op{Op: op}); err != nil {
return nil, err
}
refManager := file.NewRefManager(cm, v.Name())
return &fileOp{
op: op.File,
md: cm,
numInputs: len(v.Inputs()),
w: w,
solver: NewFileOpSolver(w, &file.Backend{}, file.NewRefManager(cm, v.Name())),
refManager: refManager,
numInputs: len(v.Inputs()),
parallelism: parallelism,
}, nil
}
Expand Down Expand Up @@ -168,7 +167,8 @@ func (f *fileOp) Exec(ctx context.Context, g session.Group, inputs []solver.Resu
inpRefs = append(inpRefs, workerRef.ImmutableRef)
}

outs, err := f.solver.Solve(ctx, inpRefs, f.op.Actions, g)
fs := NewFileOpSolver(f.w, &file.Backend{}, f.refManager)
outs, err := fs.Solve(ctx, inpRefs, f.op.Actions, g)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit a1ae2bd

Please sign in to comment.