Browse code

[19.03] vendor: moby/buildkit v0.6.4-26-ga1e4f48e

full diff: https://github.com/moby/buildkit/compare/4cb720ef6483b43020c9037726de47353ac8ad9b...a1e4f48e712360e6292819e55285e1bbacce99d4

Brings in the cherry-picks from moby/buildkit#1596 and moby/buildkit#1598 :

- Add --force flag in git fetch command
- Fix socket handling during copy (Treat unix sockets as regular files)
- Remotecache: Only visit each item once when walking results.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2020/07/28 03:17:05
Showing 5 changed files
... ...
@@ -26,7 +26,7 @@ github.com/imdario/mergo                            7c29201646fa3de8506f70121347
26 26
 golang.org/x/sync                                   e225da77a7e68af35c70ccbf71af2b83e6acac3c
27 27
 
28 28
 # buildkit
29
-github.com/moby/buildkit                            4cb720ef6483b43020c9037726de47353ac8ad9b # v0.6.4-20-g4cb720ef
29
+github.com/moby/buildkit                            a1e4f48e712360e6292819e55285e1bbacce99d4 # v0.6.4-26-ga1e4f48e
30 30
 github.com/tonistiigi/fsutil                        6c909ab392c173a4264ae1bfcbc0450b9aac0c7d
31 31
 github.com/grpc-ecosystem/grpc-opentracing          8e809c8a86450a29b90dcc9efbf062d0fe6d9746
32 32
 github.com/opentracing/opentracing-go               1361b9cd60be79c4c3a7fa9841b3c132e40066a7
... ...
@@ -40,6 +40,9 @@ func NewFileHash(path string, fi os.FileInfo) (hash.Hash, error) {
40 40
 }
41 41
 
42 42
 func NewFromStat(stat *fstypes.Stat) (hash.Hash, error) {
43
+	// Clear the socket bit since archive/tar.FileInfoHeader does not handle it
44
+	stat.Mode &^= uint32(os.ModeSocket)
45
+
43 46
 	fi := &statInfo{stat}
44 47
 	hdr, err := tar.FileInfoHeader(fi, stat.Linkname)
45 48
 	if err != nil {
... ...
@@ -220,6 +220,7 @@ func (cs *cacheResultStorage) LoadWithParents(ctx context.Context, res solver.Ca
220 220
 
221 221
 	m := map[string]solver.Result{}
222 222
 
223
+	visited := make(map[*item]struct{})
223 224
 	if err := v.walkAllResults(func(i *item) error {
224 225
 		if i.result == nil {
225 226
 			return nil
... ...
@@ -236,7 +237,7 @@ func (cs *cacheResultStorage) LoadWithParents(ctx context.Context, res solver.Ca
236 236
 			m[id] = worker.NewWorkerRefResult(ref, cs.w)
237 237
 		}
238 238
 		return nil
239
-	}); err != nil {
239
+	}, visited); err != nil {
240 240
 		for _, v := range m {
241 241
 			v.Release(context.TODO())
242 242
 		}
... ...
@@ -128,13 +128,17 @@ func (c *item) LinkFrom(rec solver.CacheExporterRecord, index int, selector stri
128 128
 	c.links[index][link{src: src, selector: selector}] = struct{}{}
129 129
 }
130 130
 
131
-func (c *item) walkAllResults(fn func(i *item) error) error {
131
+func (c *item) walkAllResults(fn func(i *item) error, visited map[*item]struct{}) error {
132
+	if _, ok := visited[c]; ok {
133
+		return nil
134
+	}
135
+	visited[c] = struct{}{}
132 136
 	if err := fn(c); err != nil {
133 137
 		return err
134 138
 	}
135 139
 	for _, links := range c.links {
136 140
 		for l := range links {
137
-			if err := l.src.walkAllResults(fn); err != nil {
141
+			if err := l.src.walkAllResults(fn, visited); err != nil {
138 142
 				return err
139 143
 			}
140 144
 		}
... ...
@@ -272,8 +272,9 @@ func (gs *gitSourceHandler) Snapshot(ctx context.Context) (out cache.ImmutableRe
272 272
 		}
273 273
 		args = append(args, "origin")
274 274
 		if !isCommitSHA(ref) {
275
-			args = append(args, ref+":tags/"+ref)
276
-			// local refs are needed so they would be advertised on next fetches
275
+			args = append(args, "--force", ref+":tags/"+ref)
276
+			// local refs are needed so they would be advertised on next fetches. Force is used
277
+			// in case the ref is a branch and it now points to a different commit sha
277 278
 			// TODO: is there a better way to do this?
278 279
 		}
279 280
 		if _, err := gitWithinDir(ctx, gitDir, "", args...); err != nil {