vendor: github.com/moby/buildkit v0.12.4

full diff: https://github.com/moby/buildkit/compare/v0.12.3...v0.12.4

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
Paweł Gronowski 2023-12-04 10:56:20 +01:00
parent 029519a149
commit c8134fa046
No known key found for this signature in database
GPG key ID: B85EFCFE26DEF92A
7 changed files with 50 additions and 31 deletions

View file

@ -61,7 +61,7 @@ require (
github.com/miekg/dns v1.1.43
github.com/mistifyio/go-zfs/v3 v3.0.1
github.com/mitchellh/copystructure v1.2.0
github.com/moby/buildkit v0.12.3
github.com/moby/buildkit v0.12.4
github.com/moby/ipvs v1.1.0
github.com/moby/locker v1.0.1
github.com/moby/patternmatcher v0.6.0

View file

@ -912,8 +912,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
github.com/moby/buildkit v0.8.1/go.mod h1:/kyU1hKy/aYCuP39GZA9MaKioovHku57N6cqlKZIaiQ=
github.com/moby/buildkit v0.12.3 h1:cFaPVnyC0PwAP5xHHfzdU5v9rgQrCi6HnGSg3WuFKp4=
github.com/moby/buildkit v0.12.3/go.mod h1:adB4y0SxxX8trnrY+oEulb48ODLqPO6pKMF0ppGcCoI=
github.com/moby/buildkit v0.12.4 h1:yKZDsObXLKarXqUx7YMnaB+TKv810bBhq0XLFWbkjT0=
github.com/moby/buildkit v0.12.4/go.mod h1:XG74uz06nPWQpnxYwgCryrVidvor0+ElUxGosbZPQG4=
github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ=
github.com/moby/ipvs v1.1.0/go.mod h1:4VJMWuf098bsUMmZEiD4Tjk/O7mOn3l1PTD3s4OoYAs=
github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg=

View file

@ -55,15 +55,17 @@ func (ck *CacheKey) Output() Index {
}
func (ck *CacheKey) clone() *CacheKey {
ck.mu.RLock()
nk := &CacheKey{
ID: ck.ID,
digest: ck.digest,
vtx: ck.vtx,
output: ck.output,
ids: map[*cacheManager]string{},
ids: make(map[*cacheManager]string, len(ck.ids)),
}
for cm, id := range ck.ids {
nk.ids[cm] = id
}
ck.mu.RUnlock()
return nk
}

View file

@ -101,34 +101,41 @@ func (cm *combinedCacheManager) Save(key *CacheKey, s Result, createdAt time.Tim
}
func (cm *combinedCacheManager) Records(ctx context.Context, ck *CacheKey) ([]*CacheRecord, error) {
ck.mu.RLock()
if len(ck.ids) == 0 {
ck.mu.RUnlock()
return nil, errors.Errorf("no results")
}
cms := make([]*cacheManager, 0, len(ck.ids))
for cm := range ck.ids {
cms = append(cms, cm)
}
ck.mu.RUnlock()
records := map[string]*CacheRecord{}
var mu sync.Mutex
eg, _ := errgroup.WithContext(context.TODO())
for c := range ck.ids {
func(c *cacheManager) {
eg.Go(func() error {
recs, err := c.Records(ctx, ck)
if err != nil {
return err
}
mu.Lock()
for _, rec := range recs {
if _, ok := records[rec.ID]; !ok || c == cm.main {
if c == cm.main {
rec.Priority = 1
}
records[rec.ID] = rec
for _, c := range cms {
c := c
eg.Go(func() error {
recs, err := c.Records(ctx, ck)
if err != nil {
return err
}
mu.Lock()
for _, rec := range recs {
if _, ok := records[rec.ID]; !ok || c == cm.main {
if c == cm.main {
rec.Priority = 1
}
records[rec.ID] = rec
}
mu.Unlock()
return nil
})
}(c)
}
mu.Unlock()
return nil
})
}
if err := eg.Wait(); err != nil {

View file

@ -85,8 +85,9 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
r CacheExporterRecord
selector digest.Digest
}
k := e.k.clone() // protect against *CacheKey internal ids mutation from other exports
recKey := rootKey(e.k.Digest(), e.k.Output())
recKey := rootKey(k.Digest(), k.Output())
rec := t.Add(recKey)
allRec := []CacheExporterRecord{rec}
@ -97,7 +98,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
}
exportRecord := opt.ExportRoots
if len(e.k.Deps()) > 0 {
if len(deps) > 0 {
exportRecord = true
}
@ -126,7 +127,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
if opt.CompressionOpt != nil {
for _, r := range remotes { // record all remaining remotes as well
rec := t.Add(recKey)
rec.AddResult(e.k.vtx, int(e.k.output), v.CreatedAt, r)
rec.AddResult(k.vtx, int(k.output), v.CreatedAt, r)
variants = append(variants, rec)
}
}
@ -147,7 +148,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
if opt.CompressionOpt != nil {
for _, r := range remotes { // record all remaining remotes as well
rec := t.Add(recKey)
rec.AddResult(e.k.vtx, int(e.k.output), v.CreatedAt, r)
rec.AddResult(k.vtx, int(k.output), v.CreatedAt, r)
variants = append(variants, rec)
}
}
@ -155,7 +156,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
if remote != nil {
for _, rec := range allRec {
rec.AddResult(e.k.vtx, int(e.k.output), v.CreatedAt, remote)
rec.AddResult(k.vtx, int(k.output), v.CreatedAt, remote)
}
}
allRec = append(allRec, variants...)
@ -198,7 +199,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
}
}
for cm, id := range e.k.ids {
for cm, id := range k.ids {
if _, err := addBacklinks(t, rec, cm, id, bkm); err != nil {
return nil, err
}

View file

@ -762,6 +762,9 @@ func (h *HistoryQueue) Listen(ctx context.Context, req *controlapi.BuildHistoryR
}()
}
// make a copy of events for active builds so we don't keep a lock during grpc send
actives := make([]*controlapi.BuildHistoryEvent, 0, len(h.active))
for _, e := range h.active {
if req.Ref != "" && e.Ref != req.Ref {
continue
@ -769,7 +772,7 @@ func (h *HistoryQueue) Listen(ctx context.Context, req *controlapi.BuildHistoryR
if _, ok := h.deleted[e.Ref]; ok {
continue
}
sub.send(&controlapi.BuildHistoryEvent{
actives = append(actives, &controlapi.BuildHistoryEvent{
Type: controlapi.BuildHistoryEventType_STARTED,
Record: e,
})
@ -777,6 +780,12 @@ func (h *HistoryQueue) Listen(ctx context.Context, req *controlapi.BuildHistoryR
h.mu.Unlock()
for _, e := range actives {
if err := f(e); err != nil {
return err
}
}
if !req.ActiveOnly {
events := []*controlapi.BuildHistoryEvent{}
if err := h.opt.DB.View(func(tx *bolt.Tx) error {
@ -810,7 +819,7 @@ func (h *HistoryQueue) Listen(ctx context.Context, req *controlapi.BuildHistoryR
}
h.mu.Unlock()
for _, e := range events {
if e.Record == nil {
if e == nil || e.Record == nil {
continue
}
if err := f(e); err != nil {

2
vendor/modules.txt vendored
View file

@ -680,7 +680,7 @@ github.com/mitchellh/hashstructure/v2
# github.com/mitchellh/reflectwalk v1.0.2
## explicit
github.com/mitchellh/reflectwalk
# github.com/moby/buildkit v0.12.3
# github.com/moby/buildkit v0.12.4
## explicit; go 1.20
github.com/moby/buildkit/api/services/control
github.com/moby/buildkit/api/types