From 23774ada04cacf85cdda55988657b23eb717b8e0 Mon Sep 17 00:00:00 2001 From: Kevin Gentile Date: Thu, 13 Apr 2023 16:49:10 -0400 Subject: vendor: github.com/moby/buildkit v0.10.7-0.20230412161310-d52b2d584242 Signed-off-by: Kevin Gentile --- vendor.mod | 2 +- vendor.sum | 4 ++-- vendor/github.com/moby/buildkit/cache/manager.go | 9 ++++++++- vendor/github.com/moby/buildkit/cache/opts.go | 11 +++++++++++ .../moby/buildkit/cache/remotecache/local/local.go | 11 ++++++++++- .../github.com/moby/buildkit/executor/oci/user.go | 13 +++++++++++++ .../moby/buildkit/util/contentutil/multiprovider.go | 21 +++++++++++++++++++++ vendor/modules.txt | 2 +- 8 files changed, 67 insertions(+), 6 deletions(-) diff --git a/vendor.mod b/vendor.mod index 55852937b3..f9837458a4 100644 --- a/vendor.mod +++ b/vendor.mod @@ -50,7 +50,7 @@ require ( github.com/klauspost/compress v1.15.12 github.com/miekg/dns v1.1.43 github.com/mistifyio/go-zfs v2.1.2-0.20190413222219-f784269be439+incompatible - github.com/moby/buildkit v0.10.7-0.20230306143919-70f2ad56d3e5 + github.com/moby/buildkit v0.10.7-0.20230412161310-d52b2d584242 github.com/moby/ipvs v1.1.0 github.com/moby/locker v1.0.1 github.com/moby/patternmatcher v0.5.0 diff --git a/vendor.sum b/vendor.sum index 65a702ffd6..58d1120f14 100644 --- a/vendor.sum +++ b/vendor.sum @@ -728,8 +728,8 @@ github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0Qu github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/osext v0.0.0-20151018003038-5e2d6d41470f/go.mod h1:OkQIRizQZAeMln+1tSwduZz7+Af5oFlKirV/MSYes2A= -github.com/moby/buildkit v0.10.7-0.20230306143919-70f2ad56d3e5 h1:1CEKLCfx4WEWbP4A+cI61IR6pC5h6cAN+20CXsU7NRU= -github.com/moby/buildkit v0.10.7-0.20230306143919-70f2ad56d3e5/go.mod h1:tQuuyTWtOb9D+RE425cwOCUkX0/oZ+5iBZ+uWpWQ9bU= +github.com/moby/buildkit v0.10.7-0.20230412161310-d52b2d584242 h1:YEWromfSEDvSx13xK7jZwoNTNnYEgpguSpedsXpZ6PA= +github.com/moby/buildkit v0.10.7-0.20230412161310-d52b2d584242/go.mod h1:tQuuyTWtOb9D+RE425cwOCUkX0/oZ+5iBZ+uWpWQ9bU= github.com/moby/ipvs v1.1.0 h1:ONN4pGaZQgAx+1Scz5RvWV4Q7Gb+mvfRh3NsPS+1XQQ= github.com/moby/ipvs v1.1.0/go.mod h1:4VJMWuf098bsUMmZEiD4Tjk/O7mOn3l1PTD3s4OoYAs= github.com/moby/locker v1.0.1 h1:fOXqR41zeveg4fFODix+1Ch4mj/gT0NE1XJbp/epuBg= diff --git a/vendor/github.com/moby/buildkit/cache/manager.go b/vendor/github.com/moby/buildkit/cache/manager.go index 58e28b4743..983f7cd529 100644 --- a/vendor/github.com/moby/buildkit/cache/manager.go +++ b/vendor/github.com/moby/buildkit/cache/manager.go @@ -301,7 +301,14 @@ func (cm *cacheManager) GetByBlob(ctx context.Context, desc ocispecs.Descriptor, cm.records[id] = rec - return rec.ref(true, descHandlers, nil), nil + ref := rec.ref(true, descHandlers, nil) + if s := unlazySessionOf(opts...); s != nil { + if err := ref.unlazy(ctx, ref.descHandlers, ref.progress, s, true); err != nil { + return nil, err + } + } + + return ref, nil } // init loads all snapshots from metadata state and tries to load the records diff --git a/vendor/github.com/moby/buildkit/cache/opts.go b/vendor/github.com/moby/buildkit/cache/opts.go index 92df9989d9..2a287640b0 100644 --- a/vendor/github.com/moby/buildkit/cache/opts.go +++ b/vendor/github.com/moby/buildkit/cache/opts.go @@ -37,3 +37,14 @@ func (m NeedsRemoteProviderError) Error() string { } type ProgressKey struct{} + +type Unlazy session.Group + +func unlazySessionOf(opts ...RefOption) session.Group { + for _, opt := range opts { + if opt, ok := opt.(session.Group); ok { + return opt + } + } + return nil +} diff --git a/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go b/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go index 18c73364c0..a6f2052725 100644 --- a/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go +++ b/vendor/github.com/moby/buildkit/cache/remotecache/local/local.go @@ -98,7 +98,16 @@ func getContentStore(ctx context.Context, sm *session.Manager, g session.Group, if err != nil { return nil, err } - return sessioncontent.NewCallerStore(caller, storeID), nil + return &unlazyProvider{sessioncontent.NewCallerStore(caller, storeID), g}, nil +} + +type unlazyProvider struct { + content.Store + s session.Group +} + +func (p *unlazyProvider) UnlazySession(desc ocispecs.Descriptor) session.Group { + return p.s } func attrsToCompression(attrs map[string]string) (*compression.Config, error) { diff --git a/vendor/github.com/moby/buildkit/executor/oci/user.go b/vendor/github.com/moby/buildkit/executor/oci/user.go index eb459f391f..bb58e834f6 100644 --- a/vendor/github.com/moby/buildkit/executor/oci/user.go +++ b/vendor/github.com/moby/buildkit/executor/oci/user.go @@ -91,6 +91,7 @@ func parseUID(str string) (uint32, error) { // once the PR in containerd is merged we should remove this function. func WithUIDGID(uid, gid uint32, sgids []uint32) containerdoci.SpecOpts { return func(_ context.Context, _ containerdoci.Client, _ *containers.Container, s *containerdoci.Spec) error { + defer ensureAdditionalGids(s) setProcess(s) s.Process.User.UID = uid s.Process.User.GID = gid @@ -106,3 +107,15 @@ func setProcess(s *containerdoci.Spec) { s.Process = &specs.Process{} } } + +// ensureAdditionalGids ensures that the primary GID is also included in the additional GID list. +// From https://github.com/containerd/containerd/blob/v1.7.0-beta.4/oci/spec_opts.go#L124-L133 +func ensureAdditionalGids(s *containerdoci.Spec) { + setProcess(s) + for _, f := range s.Process.User.AdditionalGids { + if f == s.Process.User.GID { + return + } + } + s.Process.User.AdditionalGids = append([]uint32{s.Process.User.GID}, s.Process.User.AdditionalGids...) +} diff --git a/vendor/github.com/moby/buildkit/util/contentutil/multiprovider.go b/vendor/github.com/moby/buildkit/util/contentutil/multiprovider.go index 469096d340..aba096d7c3 100644 --- a/vendor/github.com/moby/buildkit/util/contentutil/multiprovider.go +++ b/vendor/github.com/moby/buildkit/util/contentutil/multiprovider.go @@ -6,6 +6,7 @@ import ( "github.com/containerd/containerd/content" "github.com/containerd/containerd/errdefs" + "github.com/moby/buildkit/session" digest "github.com/opencontainers/go-digest" ocispecs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" @@ -90,3 +91,23 @@ func (mp *MultiProvider) Add(dgst digest.Digest, p content.Provider) { defer mp.mu.Unlock() mp.sub[dgst] = p } + +func (mp *MultiProvider) UnlazySession(desc ocispecs.Descriptor) session.Group { + type unlazySession interface { + UnlazySession(ocispecs.Descriptor) session.Group + } + + mp.mu.RLock() + if p, ok := mp.sub[desc.Digest]; ok { + mp.mu.RUnlock() + if cd, ok := p.(unlazySession); ok { + return cd.UnlazySession(desc) + } + } else { + mp.mu.RUnlock() + } + if cd, ok := mp.base.(unlazySession); ok { + return cd.UnlazySession(desc) + } + return nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 641f9c6fdc..afc790edde 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -486,7 +486,7 @@ github.com/mistifyio/go-zfs # github.com/mitchellh/hashstructure/v2 v2.0.2 ## explicit; go 1.14 github.com/mitchellh/hashstructure/v2 -# github.com/moby/buildkit v0.10.7-0.20230306143919-70f2ad56d3e5 +# github.com/moby/buildkit v0.10.7-0.20230412161310-d52b2d584242 ## explicit; go 1.17 github.com/moby/buildkit/api/services/control github.com/moby/buildkit/api/types -- cgit v1.2.1