From 9cfce302145a493571df138888485999cd6172ce Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 11 Oct 2018 21:48:26 +0200 Subject: [PATCH] bump buildkit to c7bb575343df0cbfeab8b5b28149630b8153fcc6 Relevant changes: - buildkit#667 gateway: check for `ReadDir` and `StatFile` caps on client side - buildkit#668 dockerfile: fix ssh required option - buildkit#669 dockerfile: update default copy image - buildkit#670 solver: specify SSH key ID in error message when required key was not forwarded - buildkit#673 solver: fix possible nil dereference - buildkit#672 fix setting uncompressed label on content - buildkit#680 dockerfile: fix empty dest directory panic Signed-off-by: Sebastiaan van Stijn --- vendor.conf | 2 +- .../dockerfile/dockerfile2llb/convert.go | 6 +-- .../instructions/commands_runmount.go | 2 +- .../frontend/gateway/grpcclient/client.go | 6 +++ .../snapshot/blobmapping/snapshotter.go | 13 +++++- .../github.com/moby/buildkit/solver/index.go | 10 +++-- .../buildkit/solver/llbsolver/ops/exec.go | 2 +- .../moby/buildkit/util/contentutil/refs.go | 42 ++++++++++++++++++- 8 files changed, 71 insertions(+), 12 deletions(-) diff --git a/vendor.conf b/vendor.conf index 64541e9ca1..4da10f9585 100644 --- a/vendor.conf +++ b/vendor.conf @@ -26,7 +26,7 @@ github.com/imdario/mergo v0.3.6 golang.org/x/sync 1d60e4601c6fd243af51cc01ddf169918a5407ca # buildkit -github.com/moby/buildkit 520201006c9dc676da9cf9655337ac711f7f127d +github.com/moby/buildkit c7bb575343df0cbfeab8b5b28149630b8153fcc6 github.com/tonistiigi/fsutil f567071bed2416e4d87d260d3162722651182317 github.com/grpc-ecosystem/grpc-opentracing 8e809c8a86450a29b90dcc9efbf062d0fe6d9746 github.com/opentracing/opentracing-go 1361b9cd60be79c4c3a7fa9841b3c132e40066a7 diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go index e6a52d8c5f..5342046d71 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/dockerfile2llb/convert.go @@ -35,7 +35,7 @@ const ( localNameContext = "context" historyComment = "buildkit.dockerfile.v0" - DefaultCopyImage = "tonistiigi/copy:v0.1.5@sha256:eab89b76ffbb3c807663a67a41e8be31b8a0e362d7fb074a55bddace563a28bb" + DefaultCopyImage = "tonistiigi/copy:v0.1.7@sha256:9aab7d9ab369c6daf4831bf0653f7592110ab4b7e8a33fee2b9dca546e9d3089" ) type ConvertOpt struct { @@ -212,7 +212,7 @@ func Dockerfile2LLB(ctx context.Context, dt []byte, opt ConvertOpt) (*llb.State, eg.Go(func() error { ref, err := reference.ParseNormalizedNamed(d.stage.BaseName) if err != nil { - return err + return errors.Wrapf(err, "failed to parse stage name %q", d.stage.BaseName) } platform := d.platform if platform == nil { @@ -653,7 +653,7 @@ func dispatchCopy(d *dispatchState, c instructions.SourcesAndDest, sourceState l img := llb.Image(opt.copyImage, llb.MarkImageInternal, llb.Platform(opt.buildPlatforms[0]), WithInternalName("helper image for file operations")) dest := path.Join(".", pathRelativeToWorkingDir(d.state, c.Dest())) - if c.Dest() == "." || c.Dest()[len(c.Dest())-1] == filepath.Separator { + if c.Dest() == "." || c.Dest() == "" || c.Dest()[len(c.Dest())-1] == filepath.Separator { dest += string(filepath.Separator) } args := []string{"copy"} diff --git a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go index 1c33ceed85..2540a7ea7f 100644 --- a/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go +++ b/vendor/github.com/moby/buildkit/frontend/dockerfile/instructions/commands_runmount.go @@ -136,7 +136,7 @@ func parseMount(value string) (*Mount, error) { roAuto = false continue case "required": - if m.Type == "secret" { + if m.Type == "secret" || m.Type == "ssh" { m.Required = true continue } diff --git a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go index 5e87fa57e5..d4e0525d89 100644 --- a/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go +++ b/vendor/github.com/moby/buildkit/frontend/gateway/grpcclient/client.go @@ -356,6 +356,9 @@ func (r *reference) ReadFile(ctx context.Context, req client.ReadRequest) ([]byt } func (r *reference) ReadDir(ctx context.Context, req client.ReadDirRequest) ([]*fstypes.Stat, error) { + if err := r.c.caps.Supports(pb.CapReadDir); err != nil { + return nil, err + } rdr := &pb.ReadDirRequest{ DirPath: req.Path, IncludePattern: req.IncludePattern, @@ -369,6 +372,9 @@ func (r *reference) ReadDir(ctx context.Context, req client.ReadDirRequest) ([]* } func (r *reference) StatFile(ctx context.Context, req client.StatRequest) (*fstypes.Stat, error) { + if err := r.c.caps.Supports(pb.CapStatFile); err != nil { + return nil, err + } rdr := &pb.StatFileRequest{ Path: req.Path, Ref: r.id, diff --git a/vendor/github.com/moby/buildkit/snapshot/blobmapping/snapshotter.go b/vendor/github.com/moby/buildkit/snapshot/blobmapping/snapshotter.go index d6861ae5d6..e145235a29 100644 --- a/vendor/github.com/moby/buildkit/snapshot/blobmapping/snapshotter.go +++ b/vendor/github.com/moby/buildkit/snapshot/blobmapping/snapshotter.go @@ -107,10 +107,21 @@ func (s *Snapshotter) GetBlob(ctx context.Context, key string) (digest.Digest, d // Checks that there is a blob in the content store. // If same blob has already been set then this is a noop. func (s *Snapshotter) SetBlob(ctx context.Context, key string, diffID, blobsum digest.Digest) error { - _, err := s.opt.Content.Info(ctx, blobsum) + info, err := s.opt.Content.Info(ctx, blobsum) if err != nil { return err } + if _, ok := info.Labels["containerd.io/uncompressed"]; !ok { + labels := map[string]string{ + "containerd.io/uncompressed": diffID.String(), + } + if _, err := s.opt.Content.Update(ctx, content.Info{ + Digest: blobsum, + Labels: labels, + }, "labels.containerd.io/uncompressed"); err != nil { + return err + } + } md, _ := s.opt.MetadataStore.Get(key) v, err := metadata.NewValue(DiffPair{DiffID: diffID, Blobsum: blobsum}) diff --git a/vendor/github.com/moby/buildkit/solver/index.go b/vendor/github.com/moby/buildkit/solver/index.go index 1bb17d8944..78a2cca256 100644 --- a/vendor/github.com/moby/buildkit/solver/index.go +++ b/vendor/github.com/moby/buildkit/solver/index.go @@ -211,10 +211,12 @@ func (ei *edgeIndex) getAllMatches(k *CacheKey) []string { for _, d := range dd { ll := CacheInfoLink{Input: Index(i), Digest: k.Digest(), Output: k.Output(), Selector: d.Selector} for _, ckID := range d.CacheKey.CacheKey.indexIDs { - if l, ok := ei.items[ckID].links[ll]; ok { - if _, ok := l[m]; ok { - found = true - break + if item, ok := ei.items[ckID]; ok { + if l, ok := item.links[ll]; ok { + if _, ok := l[m]; ok { + found = true + break + } } } } diff --git a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go index e91872459a..9eb9968a14 100644 --- a/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go +++ b/vendor/github.com/moby/buildkit/solver/llbsolver/ops/exec.go @@ -302,7 +302,7 @@ func (e *execOp) getSSHMountable(ctx context.Context, m *pb.Mount) (cache.Mounta return nil, nil } if st, ok := status.FromError(err); ok && st.Code() == codes.Unimplemented { - return nil, errors.Errorf("no ssh forwarded from the client") + return nil, errors.Errorf("no SSH key %q forwarded from the client", m.SSHOpt.ID) } return nil, err } diff --git a/vendor/github.com/moby/buildkit/util/contentutil/refs.go b/vendor/github.com/moby/buildkit/util/contentutil/refs.go index b3a10d1505..9df84063c0 100644 --- a/vendor/github.com/moby/buildkit/util/contentutil/refs.go +++ b/vendor/github.com/moby/buildkit/util/contentutil/refs.go @@ -3,11 +3,16 @@ package contentutil import ( "context" "net/http" + "sync" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes/docker" + "github.com/docker/docker/pkg/locker" + digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" + "github.com/pkg/errors" ) func ProviderFromRef(ref string) (ocispec.Descriptor, content.Provider, error) { @@ -38,11 +43,13 @@ func IngesterFromRef(ref string) (content.Ingester, error) { } return &ingester{ + locker: locker.New(), pusher: pusher, }, nil } type ingester struct { + locker *locker.Locker pusher remotes.Pusher } @@ -53,5 +60,38 @@ func (w *ingester) Writer(ctx context.Context, opts ...content.WriterOpt) (conte return nil, err } } - return w.pusher.Push(ctx, wo.Desc) + if wo.Ref == "" { + return nil, errors.Wrap(errdefs.ErrInvalidArgument, "ref must not be empty") + } + w.locker.Lock(wo.Ref) + var once sync.Once + unlock := func() { + once.Do(func() { + w.locker.Unlock(wo.Ref) + }) + } + writer, err := w.pusher.Push(ctx, wo.Desc) + if err != nil { + return nil, err + } + return &lockedWriter{unlock: unlock, Writer: writer}, nil +} + +type lockedWriter struct { + unlock func() + content.Writer +} + +func (w *lockedWriter) Commit(ctx context.Context, size int64, expected digest.Digest, opts ...content.Opt) error { + err := w.Writer.Commit(ctx, size, expected, opts...) + if err == nil { + w.unlock() + } + return err +} + +func (w *lockedWriter) Close() error { + err := w.Writer.Close() + w.unlock() + return err }