1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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

full diff: https://github.com/moby/buildkit/compare/v0.8.2...v0.8.3

- vendor containerd (required for rootless overlayfs on kernel 5.11)
    - not included to avoid depending on a fork
- Add retry on image push 5xx errors
- contenthash: include basename in content checksum for wildcards
- Fix missing mounts in execOp cache map
- Add regression test for run cache not considering mounts
- Add hack to preserve Dockerfile RUN cache compatibility after mount cache bugfix

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-05-26 13:33:04 +02:00
parent c6134474c2
commit 79ee285d76
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
8 changed files with 49 additions and 15 deletions

View file

@ -33,7 +33,7 @@ github.com/imdario/mergo 1afb36080aec31e0d1528973ebe6
golang.org/x/sync 6e8e738ad208923de99951fe0b48239bfd864f28 golang.org/x/sync 6e8e738ad208923de99951fe0b48239bfd864f28
# buildkit # buildkit
github.com/moby/buildkit 9065b18ba4633c75862befca8188de4338d9f94a # v0.8.2 github.com/moby/buildkit 81c2cbd8a418918d62b71e347a00034189eea455 # v0.8.3
github.com/tonistiigi/fsutil 0834f99b7b85462efb69b4f571a4fa3ca7da5ac9 github.com/tonistiigi/fsutil 0834f99b7b85462efb69b4f571a4fa3ca7da5ac9
github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2 github.com/tonistiigi/units 6950e57a87eaf136bbe44ef2ec8e75b9e3569de2
github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746

View file

@ -406,18 +406,20 @@ func (cc *cacheContext) ChecksumWildcard(ctx context.Context, mountable cache.Mo
return digest.FromBytes([]byte{}), nil return digest.FromBytes([]byte{}), nil
} }
if len(wildcards) > 1 { if len(wildcards) == 1 && path.Base(p) == path.Base(wildcards[0].Path) {
return wildcards[0].Record.Digest, nil
}
digester := digest.Canonical.Digester() digester := digest.Canonical.Digester()
for i, w := range wildcards { for i, w := range wildcards {
if i != 0 { if i != 0 {
digester.Hash().Write([]byte{0}) digester.Hash().Write([]byte{0})
} }
digester.Hash().Write([]byte(path.Base(w.Path)))
digester.Hash().Write([]byte(w.Record.Digest)) digester.Hash().Write([]byte(w.Record.Digest))
} }
return digester.Digest(), nil return digester.Digest(), nil
} }
return wildcards[0].Record.Digest, nil
}
func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error) { func (cc *cacheContext) Checksum(ctx context.Context, mountable cache.Mountable, p string, followLinks bool, s session.Group) (digest.Digest, error) {
m := &mount{mountable: mountable, session: s} m := &mount{mountable: mountable, session: s}

View file

@ -9,6 +9,7 @@ require (
github.com/Microsoft/hcsshim v0.8.10 github.com/Microsoft/hcsshim v0.8.10
github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58 // indirect github.com/codahale/hdrhistogram v0.0.0-20160425231609-f8ad88b59a58 // indirect
github.com/containerd/console v1.0.1 github.com/containerd/console v1.0.1
// containerd: the actual version is replaced in replace()
github.com/containerd/containerd v1.4.1-0.20201117152358-0edc412565dc github.com/containerd/containerd v1.4.1-0.20201117152358-0edc412565dc
github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe github.com/containerd/continuity v0.0.0-20200710164510-efbc4488d8fe
github.com/containerd/go-cni v1.0.1 github.com/containerd/go-cni v1.0.1
@ -71,6 +72,11 @@ require (
) )
replace ( replace (
// containerd: Forked from 0edc412565dcc6e3d6125ff9e4b009ad4b89c638 (20201117) with:
// - `Adjust overlay tests to expect "index=off"` (#4719, for ease of cherry-picking #5076)
// - `overlay: support "userxattr" option (kernel 5.11)` (#5076)
// - `docker: avoid concurrent map access panic` (#4855)
github.com/containerd/containerd => github.com/AkihiroSuda/containerd v1.1.1-0.20210312044057-48f85a131bb8
// protobuf: corresponds to containerd // protobuf: corresponds to containerd
github.com/golang/protobuf => github.com/golang/protobuf v1.3.5 github.com/golang/protobuf => github.com/golang/protobuf v1.3.5
github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe github.com/hashicorp/go-immutable-radix => github.com/tonistiigi/go-immutable-radix v0.0.0-20170803185627-826af9ccf0fe

View file

@ -69,8 +69,8 @@ func cloneExecOp(old *pb.ExecOp) pb.ExecOp {
} }
n.Meta = &meta n.Meta = &meta
n.Mounts = nil n.Mounts = nil
for i := range n.Mounts { for i := range old.Mounts {
m := *n.Mounts[i] m := *old.Mounts[i]
n.Mounts = append(n.Mounts, &m) n.Mounts = append(n.Mounts, &m)
} }
return n return n
@ -97,6 +97,22 @@ func (e *execOp) CacheMap(ctx context.Context, g session.Group, index int) (*sol
} }
} }
// Special case for cache compatibility with buggy versions that wrongly
// excluded Exec.Mounts: for the default case of one root mount (i.e. RUN
// inside a Dockerfile), do not include the mount when generating the cache
// map.
if len(op.Mounts) == 1 &&
op.Mounts[0].Dest == "/" &&
op.Mounts[0].Selector == "" &&
!op.Mounts[0].Readonly &&
op.Mounts[0].MountType == pb.MountType_BIND &&
op.Mounts[0].CacheOpt == nil &&
op.Mounts[0].SSHOpt == nil &&
op.Mounts[0].SecretOpt == nil &&
op.Mounts[0].ResultID == "" {
op.Mounts = nil
}
dt, err := json.Marshal(struct { dt, err := json.Marshal(struct {
Type string Type string
Exec *pb.ExecOp Exec *pb.ExecOp

View file

@ -65,7 +65,7 @@ func CopyChain(ctx context.Context, ingester content.Ingester, provider content.
handlers := []images.Handler{ handlers := []images.Handler{
images.ChildrenHandler(provider), images.ChildrenHandler(provider),
filterHandler, filterHandler,
retryhandler.New(remotes.FetchHandler(ingester, &localFetcher{provider}), nil), retryhandler.New(remotes.FetchHandler(ingester, &localFetcher{provider}), func(_ []byte) {}),
} }
if err := images.Dispatch(ctx, images.Handlers(handlers...), nil, desc); err != nil { if err := images.Dispatch(ctx, images.Handlers(handlers...), nil, desc); err != nil {

View file

@ -101,7 +101,7 @@ func Config(ctx context.Context, str string, resolver remotes.Resolver, cache Co
children := childrenConfigHandler(cache, platform) children := childrenConfigHandler(cache, platform)
handlers := []images.Handler{ handlers := []images.Handler{
retryhandler.New(remotes.FetchHandler(cache, fetcher), nil), retryhandler.New(remotes.FetchHandler(cache, fetcher), func(_ []byte) {}),
children, children,
} }
if err := images.Dispatch(ctx, images.Handlers(handlers...), nil, desc); err != nil { if err := images.Dispatch(ctx, images.Handlers(handlers...), nil, desc); err != nil {

View file

@ -132,6 +132,7 @@ func (sw *streamWriter) Close() error {
func LoggerFromContext(ctx context.Context) func([]byte) { func LoggerFromContext(ctx context.Context) func([]byte) {
return func(dt []byte) { return func(dt []byte) {
pw, _, _ := progress.FromContext(ctx) pw, _, _ := progress.FromContext(ctx)
defer pw.Close()
pw.Write(identity.NewID(), client.VertexLog{ pw.Write(identity.NewID(), client.VertexLog{
Stream: stderr, Stream: stderr,
Data: []byte(dt), Data: []byte(dt),

View file

@ -9,6 +9,7 @@ import (
"time" "time"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
remoteserrors "github.com/containerd/containerd/remotes/errors"
ocispec "github.com/opencontainers/image-spec/specs-go/v1" ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -47,6 +48,14 @@ func New(f images.HandlerFunc, logger func([]byte)) images.HandlerFunc {
} }
func retryError(err error) bool { func retryError(err error) bool {
// Retry on 5xx errors
var errUnexpectedStatus remoteserrors.ErrUnexpectedStatus
if errors.As(err, &errUnexpectedStatus) &&
errUnexpectedStatus.StatusCode >= 500 &&
errUnexpectedStatus.StatusCode <= 599 {
return true
}
if errors.Is(err, io.EOF) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) { if errors.Is(err, io.EOF) || errors.Is(err, syscall.ECONNRESET) || errors.Is(err, syscall.EPIPE) {
return true return true
} }