Skip to content

Commit

Permalink
Merge pull request #2470 from tonistiigi/v0.9.3-picks
Browse files Browse the repository at this point in the history
[v0.9] cherry-pick and update containerd
  • Loading branch information
tonistiigi authored Nov 18, 2021
2 parents 60ad88a + 6d53896 commit 8d26254
Show file tree
Hide file tree
Showing 11 changed files with 119 additions and 17 deletions.
3 changes: 2 additions & 1 deletion cache/remotecache/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/moby/buildkit/cache/remotecache"
"github.com/moby/buildkit/session"
"github.com/moby/buildkit/util/contentutil"
"github.com/moby/buildkit/util/push"
"github.com/moby/buildkit/util/resolver"
"github.com/moby/buildkit/util/resolver/limited"
digest "github.com/opencontainers/go-digest"
Expand Down Expand Up @@ -49,7 +50,7 @@ func ResolveCacheExporterFunc(sm *session.Manager, hosts docker.RegistryHosts) r
ociMediatypes = b
}
remote := resolver.DefaultPool.GetResolver(hosts, ref, "push", sm, g)
pusher, err := remote.Pusher(ctx, ref)
pusher, err := push.Pusher(ctx, remote, ref)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/Microsoft/hcsshim v0.8.23
github.com/agext/levenshtein v1.2.3
github.com/containerd/console v1.0.2
github.com/containerd/containerd v1.5.8-0.20211112185055-5fde9a5b31df
github.com/containerd/containerd v1.5.8
github.com/containerd/continuity v0.1.0
github.com/containerd/fuse-overlayfs-snapshotter v1.0.2
github.com/containerd/go-cni v1.0.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ github.com/containerd/containerd v1.5.0-beta.3/go.mod h1:/wr9AVtEM7x9c+n0+stptlo
github.com/containerd/containerd v1.5.0-beta.4/go.mod h1:GmdgZd2zA2GYIBZ0w09ZvgqEq8EfBp/m3lcVZIvPHhI=
github.com/containerd/containerd v1.5.0-rc.0/go.mod h1:V/IXoMqNGgBlabz3tHD2TWDoTJseu1FGOKuoA4nNb2s=
github.com/containerd/containerd v1.5.2/go.mod h1:0DOxVqwDy2iZvrZp2JUx/E+hS0UNTVn7dJnIOwtYR4g=
github.com/containerd/containerd v1.5.8-0.20211112185055-5fde9a5b31df h1:JZBwnmueaY+BRKnzgMOYmXDXfj4njK8gqHHywu8SCpo=
github.com/containerd/containerd v1.5.8-0.20211112185055-5fde9a5b31df/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc5qtSuYx1YUb/s=
github.com/containerd/containerd v1.5.8 h1:NmkCC1/QxyZFBny8JogwLpOy2f+VEbO/f6bV2Mqtwuw=
github.com/containerd/containerd v1.5.8/go.mod h1:YdFSv5bTFLpG2HIYmfqDpSYYTDX+mc5qtSuYx1YUb/s=
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20190815185530-f2a389ac0a02/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
github.com/containerd/continuity v0.0.0-20191127005431-f65d91d395eb/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
Expand Down
8 changes: 6 additions & 2 deletions util/contentutil/refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,21 @@ func IngesterFromRef(ref string) (content.Ingester, error) {
Client: http.DefaultClient,
})

pusher, err := remote.Pusher(context.TODO(), ref)
p, err := remote.Pusher(context.TODO(), ref)
if err != nil {
return nil, err
}

return &ingester{
locker: locker.New(),
pusher: pusher,
pusher: &pusher{p},
}, nil
}

type pusher struct {
remotes.Pusher
}

type ingester struct {
locker *locker.Locker
pusher remotes.Pusher
Expand Down
32 changes: 26 additions & 6 deletions util/imageutil/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,19 +184,39 @@ func DetectManifestMediaType(ra content.ReaderAt) (string, error) {

func DetectManifestBlobMediaType(dt []byte) (string, error) {
var mfst struct {
MediaType string `json:"mediaType"`
MediaType *string `json:"mediaType"`
Config json.RawMessage `json:"config"`
Manifests json.RawMessage `json:"manifests"`
Layers json.RawMessage `json:"layers"`
}

if err := json.Unmarshal(dt, &mfst); err != nil {
return "", err
}

if mfst.MediaType != "" {
return mfst.MediaType, nil
mt := images.MediaTypeDockerSchema2ManifestList

if mfst.Config != nil || mfst.Layers != nil {
mt = images.MediaTypeDockerSchema2Manifest

if mfst.Manifests != nil {
return "", errors.Errorf("invalid ambiguous manifest and manifest list")
}
}
if mfst.Config != nil {
return images.MediaTypeDockerSchema2Manifest, nil

if mfst.MediaType != nil {
switch *mfst.MediaType {
case images.MediaTypeDockerSchema2ManifestList, specs.MediaTypeImageIndex:
if mt != images.MediaTypeDockerSchema2ManifestList {
return "", errors.Errorf("mediaType in manifest does not match manifest contents")
}
mt = *mfst.MediaType
case images.MediaTypeDockerSchema2Manifest, specs.MediaTypeImageManifest:
if mt != images.MediaTypeDockerSchema2Manifest {
return "", errors.Errorf("mediaType in manifest does not match manifest contents")
}
mt = *mfst.MediaType
}
}
return images.MediaTypeDockerSchema2ManifestList, nil
return mt, nil
}
18 changes: 17 additions & 1 deletion util/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/remotes"
"github.com/containerd/containerd/remotes/docker"
"github.com/docker/distribution/reference"
"github.com/moby/buildkit/session"
Expand All @@ -27,6 +28,21 @@ import (
"github.com/sirupsen/logrus"
)

type pusher struct {
remotes.Pusher
}

// Pusher creates and new pusher instance for resolver
// containerd resolver.Pusher() method is broken and should not be called directly
// we need to wrap to mask interface detection
func Pusher(ctx context.Context, resolver remotes.Resolver, ref string) (remotes.Pusher, error) {
p, err := resolver.Pusher(ctx, ref)
if err != nil {
return nil, err
}
return &pusher{Pusher: p}, nil
}

func Push(ctx context.Context, sm *session.Manager, sid string, provider content.Provider, manager content.Manager, dgst digest.Digest, ref string, insecure bool, hosts docker.RegistryHosts, byDigest bool, annotations map[digest.Digest]map[string]string) error {
desc := ocispec.Descriptor{
Digest: dgst,
Expand Down Expand Up @@ -65,7 +81,7 @@ func Push(ctx context.Context, sm *session.Manager, sid string, provider content

resolver := resolver.DefaultPool.GetResolver(hosts, ref, scope, sm, session.NewGroup(sid))

pusher, err := resolver.Pusher(ctx, ref)
pusher, err := Pusher(ctx, resolver, ref)
if err != nil {
return err
}
Expand Down
1 change: 1 addition & 0 deletions vendor/github.com/containerd/containerd/.mailmap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions vendor/github.com/containerd/containerd/images/image.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/containerd/containerd/version/version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ github.com/cespare/xxhash/v2
github.com/containerd/cgroups/stats/v1
# github.com/containerd/console v1.0.2
github.com/containerd/console
# github.com/containerd/containerd v1.5.8-0.20211112185055-5fde9a5b31df
# github.com/containerd/containerd v1.5.8
github.com/containerd/containerd
github.com/containerd/containerd/api/services/containers/v1
github.com/containerd/containerd/api/services/content/v1
Expand Down

0 comments on commit 8d26254

Please sign in to comment.