Browse code

vendor: update buildkit to v0.25.1

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>

Tonis Tiigi authored on 2025/10/08 07:12:21
Showing 8 changed files
... ...
@@ -55,7 +55,7 @@ require (
55 55
 	github.com/miekg/dns v1.1.66
56 56
 	github.com/mistifyio/go-zfs/v3 v3.0.1
57 57
 	github.com/mitchellh/copystructure v1.2.0
58
-	github.com/moby/buildkit v0.25.0
58
+	github.com/moby/buildkit v0.25.1
59 59
 	github.com/moby/docker-image-spec v1.3.1
60 60
 	github.com/moby/go-archive v0.1.0
61 61
 	github.com/moby/ipvs v1.1.0
... ...
@@ -392,8 +392,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
392 392
 github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
393 393
 github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
394 394
 github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
395
-github.com/moby/buildkit v0.25.0 h1:cRgh74ymzyHxS5a/lsYT4OCyVU8iC3UgkwasIEUi0og=
396
-github.com/moby/buildkit v0.25.0/go.mod h1:phM8sdqnvgK2y1dPDnbwI6veUCXHOZ6KFSl6E164tkc=
395
+github.com/moby/buildkit v0.25.1 h1:j7IlVkeNbEo+ZLoxdudYCHpmTsbwKvhgc/6UJ/mY/o8=
396
+github.com/moby/buildkit v0.25.1/go.mod h1:phM8sdqnvgK2y1dPDnbwI6veUCXHOZ6KFSl6E164tkc=
397 397
 github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
398 398
 github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
399 399
 github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
... ...
@@ -14,6 +14,7 @@ import (
14 14
 
15 15
 	"github.com/containerd/containerd/v2/core/content"
16 16
 	"github.com/containerd/containerd/v2/pkg/labels"
17
+	cerrdefs "github.com/containerd/errdefs"
17 18
 	"github.com/moby/buildkit/cache/remotecache"
18 19
 	v1 "github.com/moby/buildkit/cache/remotecache/v1"
19 20
 	"github.com/moby/buildkit/session"
... ...
@@ -440,7 +441,7 @@ type ciProvider struct {
440 440
 
441 441
 func (p *ciProvider) Info(ctx context.Context, dgst digest.Digest) (content.Info, error) {
442 442
 	if dgst != p.desc.Digest {
443
-		return content.Info{}, errors.Errorf("content not found %s", dgst)
443
+		return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
444 444
 	}
445 445
 
446 446
 	if _, err := p.loadEntry(ctx, p.desc); err != nil {
... ...
@@ -465,7 +466,7 @@ func (p *ciProvider) loadEntry(ctx context.Context, desc ocispecs.Descriptor) (*
465 465
 		return nil, err
466 466
 	}
467 467
 	if ce == nil {
468
-		return nil, errors.Errorf("blob %s not found", desc.Digest)
468
+		return nil, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", desc.Digest)
469 469
 	}
470 470
 	if p.entries == nil {
471 471
 		p.entries = make(map[digest.Digest]*actionscache.Entry)
... ...
@@ -10,6 +10,7 @@ import (
10 10
 
11 11
 	"github.com/cespare/xxhash/v2"
12 12
 	"github.com/containerd/containerd/v2/core/content"
13
+	cerrdefs "github.com/containerd/errdefs"
13 14
 	"github.com/moby/buildkit/session"
14 15
 	"github.com/moby/buildkit/solver"
15 16
 	digest "github.com/opencontainers/go-digest"
... ...
@@ -246,7 +247,7 @@ func (p DescriptorProviderPair) Info(ctx context.Context, dgst digest.Digest) (c
246 246
 		return p.InfoProvider.Info(ctx, dgst)
247 247
 	}
248 248
 	if dgst != p.Descriptor.Digest {
249
-		return content.Info{}, errors.Errorf("content not found %s", dgst)
249
+		return content.Info{}, errors.Wrapf(cerrdefs.ErrNotFound, "blob %s", dgst)
250 250
 	}
251 251
 	return content.Info{
252 252
 		Digest: p.Descriptor.Digest,
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"errors"
6 6
 	"slices"
7 7
 
8
+	cerrdefs "github.com/containerd/errdefs"
8 9
 	digest "github.com/opencontainers/go-digest"
9 10
 )
10 11
 
... ...
@@ -189,24 +190,28 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
189 189
 		if (remote == nil || opt.CompressionOpt != nil) && opt.Mode != CacheExportModeRemoteOnly {
190 190
 			res, err := cm.results.Load(ctx, res)
191 191
 			if err != nil {
192
-				return nil, err
193
-			}
194
-			remotes, err := opt.ResolveRemotes(ctx, res)
195
-			if err != nil {
196
-				return nil, err
197
-			}
198
-			res.Release(context.TODO())
199
-			if remote == nil && len(remotes) > 0 {
200
-				remote, remotes = remotes[0], remotes[1:] // pop the first element
201
-			}
202
-			if opt.CompressionOpt != nil {
203
-				for _, r := range remotes { // record all remaining remotes as well
204
-					results = append(results, CacheExportResult{
205
-						CreatedAt:  v.CreatedAt,
206
-						Result:     r,
207
-						EdgeVertex: k.vtx,
208
-						EdgeIndex:  k.output,
209
-					})
192
+				if !errors.Is(err, cerrdefs.ErrNotFound) {
193
+					return nil, err
194
+				}
195
+				remote = nil
196
+			} else {
197
+				remotes, err := opt.ResolveRemotes(ctx, res)
198
+				if err != nil {
199
+					return nil, err
200
+				}
201
+				res.Release(context.TODO())
202
+				if remote == nil && len(remotes) > 0 {
203
+					remote, remotes = remotes[0], remotes[1:] // pop the first element
204
+				}
205
+				if opt.CompressionOpt != nil {
206
+					for _, r := range remotes { // record all remaining remotes as well
207
+						results = append(results, CacheExportResult{
208
+							CreatedAt:  v.CreatedAt,
209
+							Result:     r,
210
+							EdgeVertex: k.vtx,
211
+							EdgeIndex:  k.output,
212
+						})
213
+					}
210 214
 				}
211 215
 			}
212 216
 		}
... ...
@@ -232,7 +237,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
232 232
 		for _, dep := range deps {
233 233
 			rec, err := dep.CacheKey.Exporter.ExportTo(ctx, t, opt)
234 234
 			if err != nil {
235
-				return nil, err
235
+				continue
236 236
 			}
237 237
 			for _, r := range rec {
238 238
 				srcs[i] = append(srcs[i], CacheLink{Src: r, Selector: string(dep.Selector)})
... ...
@@ -244,7 +249,7 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
244 244
 		for _, de := range e.edge.secondaryExporters {
245 245
 			recs, err := de.cacheKey.CacheKey.Exporter.ExportTo(mainCtx, t, opt)
246 246
 			if err != nil {
247
-				return nil, nil
247
+				continue
248 248
 			}
249 249
 			for _, r := range recs {
250 250
 				srcs[de.index] = append(srcs[de.index], CacheLink{Src: r, Selector: de.cacheKey.Selector.String()})
... ...
@@ -261,6 +266,14 @@ func (e *exporter) ExportTo(ctx context.Context, t CacheExporterTarget, opt Cach
261 261
 		}
262 262
 	}
263 263
 
264
+	// validate deps are present
265
+	for _, deps := range srcs {
266
+		if len(deps) == 0 {
267
+			res[e] = nil
268
+			return res[e], nil
269
+		}
270
+	}
271
+
264 272
 	if v != nil && len(deps) == 0 {
265 273
 		cm := v.cacheManager
266 274
 		key := cm.getID(v.key)
... ...
@@ -1,6 +1,8 @@
1 1
 package types
2 2
 
3 3
 import (
4
+	"encoding/json"
5
+	"maps"
4 6
 	"slices"
5 7
 
6 8
 	slsa "github.com/in-toto/in-toto-golang/in_toto/slsa_provenance/common"
... ...
@@ -311,3 +313,95 @@ func (p *ProvenancePredicateSLSA02) ConvertToSLSA1() *ProvenancePredicateSLSA1 {
311 311
 		RunDetails:      runDetails,
312 312
 	}
313 313
 }
314
+
315
+// MarshalJSON flattens ProvenanceCustomEnv into top level.
316
+func (p ProvenanceInternalParametersSLSA1) MarshalJSON() ([]byte, error) {
317
+	type Alias ProvenanceInternalParametersSLSA1
318
+	base, err := json.Marshal(Alias(p))
319
+	if err != nil {
320
+		return nil, err
321
+	}
322
+	var m map[string]any
323
+	if err := json.Unmarshal(base, &m); err != nil {
324
+		return nil, err
325
+	}
326
+	maps.Copy(m, p.ProvenanceCustomEnv)
327
+	delete(m, "ProvenanceCustomEnv")
328
+	return json.Marshal(m)
329
+}
330
+
331
+// UnmarshalJSON fills both struct fields and flattened custom env.
332
+func (p *ProvenanceInternalParametersSLSA1) UnmarshalJSON(data []byte) error {
333
+	var m map[string]any
334
+	if err := json.Unmarshal(data, &m); err != nil {
335
+		return err
336
+	}
337
+
338
+	type Alias ProvenanceInternalParametersSLSA1
339
+	var a Alias
340
+	if err := json.Unmarshal(data, &a); err != nil {
341
+		return err
342
+	}
343
+
344
+	// Unmarshal known struct again to identify its keys
345
+	structBytes, err := json.Marshal(a)
346
+	if err != nil {
347
+		return err
348
+	}
349
+	var known map[string]any
350
+	if err := json.Unmarshal(structBytes, &known); err != nil {
351
+		return err
352
+	}
353
+
354
+	for k := range known {
355
+		delete(m, k)
356
+	}
357
+
358
+	*p = ProvenanceInternalParametersSLSA1(a)
359
+	p.ProvenanceCustomEnv = m
360
+	return nil
361
+}
362
+
363
+func (p Environment) MarshalJSON() ([]byte, error) {
364
+	type Alias Environment
365
+	base, err := json.Marshal(Alias(p))
366
+	if err != nil {
367
+		return nil, err
368
+	}
369
+	var m map[string]any
370
+	if err := json.Unmarshal(base, &m); err != nil {
371
+		return nil, err
372
+	}
373
+	maps.Copy(m, p.ProvenanceCustomEnv)
374
+	delete(m, "ProvenanceCustomEnv")
375
+	return json.Marshal(m)
376
+}
377
+
378
+func (p *Environment) UnmarshalJSON(data []byte) error {
379
+	var m map[string]any
380
+	if err := json.Unmarshal(data, &m); err != nil {
381
+		return err
382
+	}
383
+
384
+	type Alias Environment
385
+	var a Alias
386
+	if err := json.Unmarshal(data, &a); err != nil {
387
+		return err
388
+	}
389
+	// Unmarshal known struct again to identify its keys
390
+	structBytes, err := json.Marshal(a)
391
+	if err != nil {
392
+		return err
393
+	}
394
+	var known map[string]any
395
+	if err := json.Unmarshal(structBytes, &known); err != nil {
396
+		return err
397
+	}
398
+
399
+	for k := range known {
400
+		delete(m, k)
401
+	}
402
+	*p = Environment(a)
403
+	p.ProvenanceCustomEnv = m
404
+	return nil
405
+}
... ...
@@ -847,6 +847,7 @@ func (s *Solver) runExporters(ctx context.Context, exporters []exporter.Exporter
847 847
 	eg, ctx := errgroup.WithContext(ctx)
848 848
 	resps := make([]map[string]string, len(exporters))
849 849
 	descs := make([]exporter.DescriptorReference, len(exporters))
850
+	var inlineCacheMu sync.Mutex
850 851
 	for i, exp := range exporters {
851 852
 		i, exp := i, exp
852 853
 		eg.Go(func() error {
... ...
@@ -865,6 +866,8 @@ func (s *Solver) runExporters(ctx context.Context, exporters []exporter.Exporter
865 865
 					}
866 866
 				}
867 867
 				inlineCache := exptypes.InlineCache(func(ctx context.Context) (*result.Result[*exptypes.InlineCacheEntry], error) {
868
+					inlineCacheMu.Lock() // ensure only one inline cache exporter runs at a time
869
+					defer inlineCacheMu.Unlock()
868 870
 					return runInlineCacheExporter(ctx, exp, inlineCacheExporter, job, cached)
869 871
 				})
870 872
 
... ...
@@ -752,7 +752,7 @@ github.com/mitchellh/hashstructure/v2
752 752
 # github.com/mitchellh/reflectwalk v1.0.2
753 753
 ## explicit
754 754
 github.com/mitchellh/reflectwalk
755
-# github.com/moby/buildkit v0.25.0
755
+# github.com/moby/buildkit v0.25.1
756 756
 ## explicit; go 1.24.0
757 757
 github.com/moby/buildkit/api/services/control
758 758
 github.com/moby/buildkit/api/types