Browse code

vendor: update buildkit to v0.18.2

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

Tonis Tiigi authored on 2024/12/17 08:43:08
Showing 12 changed files
... ...
@@ -63,7 +63,7 @@ require (
63 63
 	github.com/miekg/dns v1.1.57
64 64
 	github.com/mistifyio/go-zfs/v3 v3.0.1
65 65
 	github.com/mitchellh/copystructure v1.2.0
66
-	github.com/moby/buildkit v0.18.1
66
+	github.com/moby/buildkit v0.18.2
67 67
 	github.com/moby/docker-image-spec v1.3.1
68 68
 	github.com/moby/ipvs v1.1.0
69 69
 	github.com/moby/locker v1.0.1
... ...
@@ -364,8 +364,8 @@ github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:F
364 364
 github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
365 365
 github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
366 366
 github.com/mndrix/tap-go v0.0.0-20171203230836-629fa407e90b/go.mod h1:pzzDgJWZ34fGzaAZGFW22KVZDfyrYW+QABMrWnJBnSs=
367
-github.com/moby/buildkit v0.18.1 h1:Iwrz2F/Za2Gjkpwu3aM2LX92AFfJCJe2oNnvGNvh2Rc=
368
-github.com/moby/buildkit v0.18.1/go.mod h1:vCR5CX8NGsPTthTg681+9kdmfvkvqJBXEv71GZe5msU=
367
+github.com/moby/buildkit v0.18.2 h1:l86uBvxh4ntNoUUg3Y0eGTbKg1PbUh6tawJ4Xt75SpQ=
368
+github.com/moby/buildkit v0.18.2/go.mod h1:vCR5CX8NGsPTthTg681+9kdmfvkvqJBXEv71GZe5msU=
369 369
 github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
370 370
 github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
371 371
 github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ=
... ...
@@ -16,7 +16,6 @@ import (
16 16
 // For example, after marshalling a LLB state and sending over the wire, the
17 17
 // LLB state can be reconstructed from the definition.
18 18
 type DefinitionOp struct {
19
-	MarshalCache
20 19
 	mu         sync.Mutex
21 20
 	ops        map[digest.Digest]*pb.Op
22 21
 	defs       map[digest.Digest][]byte
... ...
@@ -8,7 +8,7 @@ import (
8 8
 )
9 9
 
10 10
 type DiffOp struct {
11
-	MarshalCache
11
+	cache       MarshalCache
12 12
 	lower       Output
13 13
 	upper       Output
14 14
 	output      Output
... ...
@@ -31,7 +31,10 @@ func (m *DiffOp) Validate(ctx context.Context, constraints *Constraints) error {
31 31
 }
32 32
 
33 33
 func (m *DiffOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
34
-	if dgst, dt, md, srcs, err := m.Load(constraints); err == nil {
34
+	cache := m.cache.Acquire()
35
+	defer cache.Release()
36
+
37
+	if dgst, dt, md, srcs, err := cache.Load(constraints); err == nil {
35 38
 		return dgst, dt, md, srcs, nil
36 39
 	}
37 40
 	if err := m.Validate(ctx, constraints); err != nil {
... ...
@@ -72,7 +75,7 @@ func (m *DiffOp) Marshal(ctx context.Context, constraints *Constraints) (digest.
72 72
 		return "", nil, nil, nil, err
73 73
 	}
74 74
 
75
-	return m.Store(dt, md, m.constraints.SourceLocations, constraints)
75
+	return cache.Store(dt, md, m.constraints.SourceLocations, constraints)
76 76
 }
77 77
 
78 78
 func (m *DiffOp) Output() Output {
... ...
@@ -51,7 +51,7 @@ type mount struct {
51 51
 }
52 52
 
53 53
 type ExecOp struct {
54
-	MarshalCache
54
+	cache       MarshalCache
55 55
 	proxyEnv    *ProxyEnv
56 56
 	root        Output
57 57
 	mounts      []*mount
... ...
@@ -63,6 +63,9 @@ type ExecOp struct {
63 63
 }
64 64
 
65 65
 func (e *ExecOp) AddMount(target string, source Output, opt ...MountOption) Output {
66
+	cache := e.cache.Acquire()
67
+	defer cache.Release()
68
+
66 69
 	m := &mount{
67 70
 		target: target,
68 71
 		source: source,
... ...
@@ -84,7 +87,7 @@ func (e *ExecOp) AddMount(target string, source Output, opt ...MountOption) Outp
84 84
 		}
85 85
 		m.output = o
86 86
 	}
87
-	e.Store(nil, nil, nil, nil)
87
+	cache.Store(nil, nil, nil, nil)
88 88
 	e.isValidated = false
89 89
 	return m.output
90 90
 }
... ...
@@ -128,7 +131,10 @@ func (e *ExecOp) Validate(ctx context.Context, c *Constraints) error {
128 128
 }
129 129
 
130 130
 func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
131
-	if dgst, dt, md, srcs, err := e.Load(c); err == nil {
131
+	cache := e.cache.Acquire()
132
+	defer cache.Release()
133
+
134
+	if dgst, dt, md, srcs, err := cache.Load(c); err == nil {
132 135
 		return dgst, dt, md, srcs, nil
133 136
 	}
134 137
 
... ...
@@ -446,7 +452,7 @@ func (e *ExecOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
446 446
 	if err != nil {
447 447
 		return "", nil, nil, nil, err
448 448
 	}
449
-	return e.Store(dt, md, e.constraints.SourceLocations, c)
449
+	return cache.Store(dt, md, e.constraints.SourceLocations, c)
450 450
 }
451 451
 
452 452
 func (e *ExecOp) Output() Output {
... ...
@@ -746,7 +746,10 @@ func (ms *marshalState) add(fa *FileAction, c *Constraints) (*fileActionState, e
746 746
 }
747 747
 
748 748
 func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
749
-	if dgst, dt, md, srcs, err := f.Load(c); err == nil {
749
+	cache := f.Acquire()
750
+	defer cache.Release()
751
+
752
+	if dgst, dt, md, srcs, err := cache.Load(c); err == nil {
750 753
 		return dgst, dt, md, srcs, nil
751 754
 	}
752 755
 
... ...
@@ -816,7 +819,7 @@ func (f *FileOp) Marshal(ctx context.Context, c *Constraints) (digest.Digest, []
816 816
 	if err != nil {
817 817
 		return "", nil, nil, nil, err
818 818
 	}
819
-	return f.Store(dt, md, f.constraints.SourceLocations, c)
819
+	return cache.Store(dt, md, f.constraints.SourceLocations, c)
820 820
 }
821 821
 
822 822
 func normalizePath(parent, p string, keepSlash bool) string {
... ...
@@ -117,30 +117,45 @@ func MarshalConstraints(base, override *Constraints) (*pb.Op, *pb.OpMetadata) {
117 117
 }
118 118
 
119 119
 type MarshalCache struct {
120
-	cache sync.Map
120
+	mu    sync.Mutex
121
+	cache map[*Constraints]*marshalCacheResult
121 122
 }
122 123
 
123
-func (mc *MarshalCache) Load(c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
124
-	v, ok := mc.cache.Load(c)
124
+type MarshalCacheInstance struct {
125
+	*MarshalCache
126
+}
127
+
128
+func (mc *MarshalCache) Acquire() *MarshalCacheInstance {
129
+	mc.mu.Lock()
130
+	return &MarshalCacheInstance{mc}
131
+}
132
+
133
+func (mc *MarshalCacheInstance) Load(c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
134
+	res, ok := mc.cache[c]
125 135
 	if !ok {
126 136
 		return "", nil, nil, nil, cerrdefs.ErrNotFound
127 137
 	}
128
-
129
-	res := v.(*marshalCacheResult)
130 138
 	return res.digest, res.dt, res.md, res.srcs, nil
131 139
 }
132 140
 
133
-func (mc *MarshalCache) Store(dt []byte, md *pb.OpMetadata, srcs []*SourceLocation, c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
141
+func (mc *MarshalCacheInstance) Store(dt []byte, md *pb.OpMetadata, srcs []*SourceLocation, c *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
134 142
 	res := &marshalCacheResult{
135 143
 		digest: digest.FromBytes(dt),
136 144
 		dt:     dt,
137 145
 		md:     md,
138 146
 		srcs:   srcs,
139 147
 	}
140
-	mc.cache.Store(c, res)
148
+	if mc.cache == nil {
149
+		mc.cache = make(map[*Constraints]*marshalCacheResult)
150
+	}
151
+	mc.cache[c] = res
141 152
 	return res.digest, res.dt, res.md, res.srcs, nil
142 153
 }
143 154
 
155
+func (mc *MarshalCacheInstance) Release() {
156
+	mc.mu.Unlock()
157
+}
158
+
144 159
 type marshalCacheResult struct {
145 160
 	digest digest.Digest
146 161
 	dt     []byte
... ...
@@ -9,7 +9,7 @@ import (
9 9
 )
10 10
 
11 11
 type MergeOp struct {
12
-	MarshalCache
12
+	cache       MarshalCache
13 13
 	inputs      []Output
14 14
 	output      Output
15 15
 	constraints Constraints
... ...
@@ -32,7 +32,10 @@ func (m *MergeOp) Validate(ctx context.Context, constraints *Constraints) error
32 32
 }
33 33
 
34 34
 func (m *MergeOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
35
-	if dgst, dt, md, srcs, err := m.Load(constraints); err == nil {
35
+	cache := m.cache.Acquire()
36
+	defer cache.Release()
37
+
38
+	if dgst, dt, md, srcs, err := cache.Load(constraints); err == nil {
36 39
 		return dgst, dt, md, srcs, nil
37 40
 	}
38 41
 
... ...
@@ -59,7 +62,7 @@ func (m *MergeOp) Marshal(ctx context.Context, constraints *Constraints) (digest
59 59
 		return "", nil, nil, nil, err
60 60
 	}
61 61
 
62
-	return m.Store(dt, md, m.constraints.SourceLocations, constraints)
62
+	return cache.Store(dt, md, m.constraints.SourceLocations, constraints)
63 63
 }
64 64
 
65 65
 func (m *MergeOp) Output() Output {
... ...
@@ -20,7 +20,7 @@ import (
20 20
 )
21 21
 
22 22
 type SourceOp struct {
23
-	MarshalCache
23
+	cache       MarshalCache
24 24
 	id          string
25 25
 	attrs       map[string]string
26 26
 	output      Output
... ...
@@ -49,7 +49,10 @@ func (s *SourceOp) Validate(ctx context.Context, c *Constraints) error {
49 49
 }
50 50
 
51 51
 func (s *SourceOp) Marshal(ctx context.Context, constraints *Constraints) (digest.Digest, []byte, *pb.OpMetadata, []*SourceLocation, error) {
52
-	if dgst, dt, md, srcs, err := s.Load(constraints); err == nil {
52
+	cache := s.cache.Acquire()
53
+	defer cache.Release()
54
+
55
+	if dgst, dt, md, srcs, err := cache.Load(constraints); err == nil {
53 56
 		return dgst, dt, md, srcs, nil
54 57
 	}
55 58
 
... ...
@@ -82,7 +85,7 @@ func (s *SourceOp) Marshal(ctx context.Context, constraints *Constraints) (diges
82 82
 		return "", nil, nil, nil, err
83 83
 	}
84 84
 
85
-	return s.Store(dt, md, s.constraints.SourceLocations, constraints)
85
+	return cache.Store(dt, md, s.constraints.SourceLocations, constraints)
86 86
 }
87 87
 
88 88
 func (s *SourceOp) Output() Output {
... ...
@@ -376,6 +376,7 @@ func toDispatchState(ctx context.Context, dt []byte, opt ConvertOpt) (*dispatchS
376 376
 					}
377 377
 				}
378 378
 				allDispatchStates.addState(ds)
379
+				ds.base = nil // reset base set by addState
379 380
 				continue
380 381
 			}
381 382
 		}
... ...
@@ -1065,6 +1066,8 @@ func (ds *dispatchState) init() {
1065 1065
 	ds.state = ds.base.state
1066 1066
 	ds.platform = ds.base.platform
1067 1067
 	ds.image = clone(ds.base.image)
1068
+	// onbuild triggers to not carry over from base stage
1069
+	ds.image.Config.OnBuild = nil
1068 1070
 	ds.baseImg = cloneX(ds.base.baseImg)
1069 1071
 	// Utilize the same path index as our base image so we propagate
1070 1072
 	// the paths we use back to the base image.
... ...
@@ -12,6 +12,7 @@ func clone(src dockerspec.DockerOCIImage) dockerspec.DockerOCIImage {
12 12
 	img.Config.Env = append([]string{}, src.Config.Env...)
13 13
 	img.Config.Cmd = append([]string{}, src.Config.Cmd...)
14 14
 	img.Config.Entrypoint = append([]string{}, src.Config.Entrypoint...)
15
+	img.Config.OnBuild = append([]string{}, src.Config.OnBuild...)
15 16
 	return img
16 17
 }
17 18
 
... ...
@@ -699,7 +699,7 @@ github.com/mitchellh/hashstructure/v2
699 699
 # github.com/mitchellh/reflectwalk v1.0.2
700 700
 ## explicit
701 701
 github.com/mitchellh/reflectwalk
702
-# github.com/moby/buildkit v0.18.1
702
+# github.com/moby/buildkit v0.18.2
703 703
 ## explicit; go 1.22.0
704 704
 github.com/moby/buildkit/api/services/control
705 705
 github.com/moby/buildkit/api/types