vendor: github.com/moby/buildkit 9b91d20367db (master, v0.24-dev)

full diff: https://github.com/moby/buildkit/compare/9b91d20367db...955c2b2f7d014cf13a0f755d298963f8c0a190b6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-06 16:47:11 +02:00
parent 46463d93bf
commit bbd18927d2
12 changed files with 166 additions and 48 deletions
+28 -18
View File
@@ -474,7 +474,18 @@ func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string,
return nil, err
}
body := resp.Body
body := &fnOnClose{
BeforeClose: func() {
r.Release(1)
},
ReadCloser: resp.Body,
}
defer func() {
if retErr != nil {
body.Close()
}
}()
encoding := strings.FieldsFunc(resp.Header.Get("Content-Encoding"), func(r rune) bool {
return r == ' ' || r == '\t' || r == ','
})
@@ -505,29 +516,33 @@ func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string,
for i := range numChunks {
readers[i], writers[i] = newPipeWriter(bufPool)
}
// keep reference of the initial body value to ensure it is closed
ibody := body
go func() {
for i := range numChunks {
select {
case queue <- i:
case <-done:
if i == 0 {
ibody.Close()
}
return // avoid leaking a goroutine if we exit early.
}
}
close(queue)
}()
r.Release(1)
for range parallelism {
go func() {
for i := range queue { // first in first out
copy := func() error {
if err := r.Acquire(ctx, 1); err != nil {
return err
}
defer r.Release(1)
var body io.ReadCloser
if i == 0 {
body = resp.Body
body = ibody
} else {
if err := r.Acquire(ctx, 1); err != nil {
return err
}
defer r.Release(1)
reqClone := req.clone()
reqClone.setOffset(offset + i*chunkSize)
nresp, err := reqClone.doWithRetries(ctx, lastHost, withErrorCheck)
@@ -564,32 +579,27 @@ func (r dockerFetcher) open(ctx context.Context, req *request, mediatype string,
},
ReadCloser: io.NopCloser(io.MultiReader(readers...)),
}
} else {
body = &fnOnClose{
BeforeClose: func() {
r.Release(1)
},
ReadCloser: body,
}
}
for i := len(encoding) - 1; i >= 0; i-- {
algorithm := strings.ToLower(encoding[i])
switch algorithm {
case "zstd":
r, err := zstd.NewReader(body,
r, err := zstd.NewReader(body.ReadCloser,
zstd.WithDecoderLowmem(false),
)
if err != nil {
return nil, err
}
body = r.IOReadCloser()
body.ReadCloser = r.IOReadCloser()
case "gzip":
body, err = gzip.NewReader(body)
r, err := gzip.NewReader(body.ReadCloser)
if err != nil {
return nil, err
}
body.ReadCloser = r
case "deflate":
body = flate.NewReader(body)
body.ReadCloser = flate.NewReader(body.ReadCloser)
case "identity", "":
// no content-encoding applied, use raw body
default:
+1 -1
View File
@@ -24,7 +24,7 @@ var (
Package = "github.com/containerd/containerd/v2"
// Version holds the complete version number. Filled in at linking time.
Version = "2.1.3+unknown"
Version = "2.1.4+unknown"
// Revision is filled with the VCS (e.g. git) revision being used to build
// the program at linking time.