Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache IDs & fix BK result caching #55

Merged
merged 12 commits into from
Apr 9, 2024
1 change: 1 addition & 0 deletions cmd/buildkitd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@ func newController(c *cli.Context, cfg *config.Config, shutdownCh chan struct{})
LeaseManager: w.LeaseManager(),
ContentStore: w.ContentStore(),
HistoryConfig: cfg.History,
RootDir: cfg.Root,
})
}

Expand Down
2 changes: 2 additions & 0 deletions control/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type Opt struct {
LeaseManager *leaseutil.Manager
ContentStore *containerdsnapshot.Store
HistoryConfig *config.HistoryConfig
RootDir string
}

type Controller struct { // TODO: ControlService
Expand Down Expand Up @@ -105,6 +106,7 @@ func NewController(opt Opt) (*Controller, error) {
SessionManager: opt.SessionManager,
Entitlements: opt.Entitlements,
HistoryQueue: hq,
RootDir: opt.RootDir,
})
if err != nil {
return nil, errors.Wrap(err, "failed to create solver")
Expand Down
18 changes: 15 additions & 3 deletions solver/jobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ type Job struct {
}

type SolverOpt struct {
ResolveOpFunc ResolveOpFunc
DefaultCache CacheManager
ResolveOpFunc ResolveOpFunc
DefaultCache CacheManager
WorkerResultGetter workerResultGetter
CommitRefFunc CommitRefFunc
RootDir string
}

func NewSolver(opts SolverOpt) *Solver {
Expand All @@ -274,7 +277,11 @@ func NewSolver(opts SolverOpt) *Solver {
// TODO: This should be hoisted up a few layers as not to be bound to the
// original solver. For now, we just need a convenient place to initialize
// it once.
simple := newSimpleSolver(opts.ResolveOpFunc, jl)
c, err := newDiskCache(opts.WorkerResultGetter, opts.RootDir)
if err != nil {
panic(err) // TODO: Handle error appropriately once the new solver code is moved.
}
simple := newSimpleSolver(opts.ResolveOpFunc, opts.CommitRefFunc, jl, c)
jl.simple = simple

jl.s = newScheduler(jl)
Expand Down Expand Up @@ -613,6 +620,11 @@ func (j *Job) CloseProgress() {
}

func (j *Job) Discard() error {
// TMP: Hack to prevent actives map deletes.
if true {
return nil
}

j.list.mu.Lock()
defer j.list.mu.Unlock()

Expand Down
3 changes: 3 additions & 0 deletions solver/llbsolver/provenance.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ func captureProvenance(ctx context.Context, res solver.CachedResultWithProvenanc
switch op := pp.(type) {
case *ops.SourceOp:
id, pin := op.Pin()
if pin == "" { // Hack: latest cache opt changes led to an empty value here. Investigate.
return nil
}
err := id.Capture(c, pin)
if err != nil {
return err
Expand Down
8 changes: 6 additions & 2 deletions solver/llbsolver/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Opt struct {
WorkerController *worker.Controller
HistoryQueue *HistoryQueue
ResourceMonitor *resources.Monitor
RootDir string
}

type Solver struct {
Expand Down Expand Up @@ -119,8 +120,11 @@ func New(opt Opt) (*Solver, error) {
s.sysSampler = sampler

s.solver = solver.NewSolver(solver.SolverOpt{
ResolveOpFunc: s.resolver(),
DefaultCache: opt.CacheManager,
ResolveOpFunc: s.resolver(),
DefaultCache: opt.CacheManager,
WorkerResultGetter: worker.NewWorkerResultGetter(opt.WorkerController),
CommitRefFunc: worker.FinalizeRef,
RootDir: opt.RootDir,
})
return s, nil
}
Expand Down
Loading
Loading