Merge pull request #177 from AkihiroSuda/vendor-containerd-20171124

vendor: update containerd to 9649a428e8c470cddc0d5a3c394f36111f940adc
docker-18.09
Tõnis Tiigi 2017-11-24 00:30:17 -08:00 committed by GitHub
commit 641ea63837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 47 additions and 119 deletions

View File

@ -139,7 +139,7 @@ The `tonistiigi/buildkit:standalone` image can be built locally using the Docker
#### Supported runc version #### Supported runc version
During development buildkit is tested with the version of runc that is being used by the containerd repository. Please refer to [runc.md](https://github.com/containerd/containerd/blob/9649a428e8c470cddc0d5a3c394f36111f940adc/RUNC.md) for more information. During development buildkit is tested with the version of runc that is being used by the containerd repository. Please refer to [runc.md](https://github.com/containerd/containerd/blob/4af5f657526a8aa5eedef734f5f29152031b1d3a/RUNC.md) for more information.
#### Contributing #### Contributing

View File

@ -17,7 +17,7 @@ type buildOpt struct {
func main() { func main() {
var opt buildOpt var opt buildOpt
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)") flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
flag.StringVar(&opt.containerd, "containerd", "9649a428e8c470cddc0d5a3c394f36111f940adc", "containerd version") flag.StringVar(&opt.containerd, "containerd", "4af5f657526a8aa5eedef734f5f29152031b1d3a", "containerd version")
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version") flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
flag.Parse() flag.Parse()

View File

@ -17,7 +17,7 @@ type buildOpt struct {
func main() { func main() {
var opt buildOpt var opt buildOpt
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)") flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
flag.StringVar(&opt.containerd, "containerd", "9649a428e8c470cddc0d5a3c394f36111f940adc", "containerd version") flag.StringVar(&opt.containerd, "containerd", "4af5f657526a8aa5eedef734f5f29152031b1d3a", "containerd version")
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version") flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
flag.Parse() flag.Parse()

View File

@ -17,7 +17,7 @@ type buildOpt struct {
func main() { func main() {
var opt buildOpt var opt buildOpt
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)") flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
flag.StringVar(&opt.containerd, "containerd", "9649a428e8c470cddc0d5a3c394f36111f940adc", "containerd version") flag.StringVar(&opt.containerd, "containerd", "4af5f657526a8aa5eedef734f5f29152031b1d3a", "containerd version")
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version") flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
flag.Parse() flag.Parse()

View File

@ -18,7 +18,7 @@ type buildOpt struct {
func main() { func main() {
var opt buildOpt var opt buildOpt
flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)") flag.StringVar(&opt.target, "target", "containerd", "target (standalone, containerd)")
flag.StringVar(&opt.containerd, "containerd", "9649a428e8c470cddc0d5a3c394f36111f940adc", "containerd version") flag.StringVar(&opt.containerd, "containerd", "4af5f657526a8aa5eedef734f5f29152031b1d3a", "containerd version")
flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version") flag.StringVar(&opt.runc, "runc", "74a17296470088de3805e138d3d87c62e613dfc4", "runc version")
flag.StringVar(&opt.buildkit, "buildkit", "master", "buildkit version") flag.StringVar(&opt.buildkit, "buildkit", "master", "buildkit version")
flag.Parse() flag.Parse()

View File

@ -1,5 +1,5 @@
ARG RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4 ARG RUNC_VERSION=74a17296470088de3805e138d3d87c62e613dfc4
ARG CONTAINERD_VERSION=9649a428e8c470cddc0d5a3c394f36111f940adc ARG CONTAINERD_VERSION=4af5f657526a8aa5eedef734f5f29152031b1d3a
ARG BUILDKIT_TARGET=standalone ARG BUILDKIT_TARGET=standalone
FROM golang:1.9-alpine AS gobuild-base FROM golang:1.9-alpine AS gobuild-base

View File

@ -6,7 +6,7 @@ github.com/davecgh/go-spew v1.1.0
github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib v1.0.0
golang.org/x/sys 9aade4d3a3b7e6d876cd3823ad20ec45fc035402 # update to 7ddbeae9ae08c6a06a59597f0c9edbc5ff2444ce wiht pkg/signal change golang.org/x/sys 9aade4d3a3b7e6d876cd3823ad20ec45fc035402 # update to 7ddbeae9ae08c6a06a59597f0c9edbc5ff2444ce wiht pkg/signal change
github.com/containerd/containerd 9649a428e8c470cddc0d5a3c394f36111f940adc github.com/containerd/containerd 4af5f657526a8aa5eedef734f5f29152031b1d3a
github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788 github.com/containerd/typeurl f6943554a7e7e88b3c14aad190bf05932da84788
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/sirupsen/logrus v1.0.0 github.com/sirupsen/logrus v1.0.0

View File

@ -158,7 +158,7 @@ To build the daemon and `ctr` simple test client, the following build system dep
* Protoc 3.x compiler and headers (download at the [Google protobuf releases page](https://github.com/google/protobuf/releases)) * Protoc 3.x compiler and headers (download at the [Google protobuf releases page](https://github.com/google/protobuf/releases))
* Btrfs headers and libraries for your distribution. Note that building the btrfs driver can be disabled via build tag removing this dependency. * Btrfs headers and libraries for your distribution. Note that building the btrfs driver can be disabled via build tag removing this dependency.
For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.1.0 release for a 64-bit Linux host: For proper results, install the `protoc` release into `/usr/local` on your build system. For example, the following commands will download and install the 3.5.0 release for a 64-bit Linux host:
``` ```
$ wget -c https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip $ wget -c https://github.com/google/protobuf/releases/download/v3.5.0/protoc-3.5.0-linux-x86_64.zip

View File

@ -133,7 +133,7 @@ type LeasesClient interface {
// during the lease eligible for garbage collection if not referenced // during the lease eligible for garbage collection if not referenced
// or retained by other resources during the lease. // or retained by other resources during the lease.
Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) Delete(ctx context.Context, in *DeleteRequest, opts ...grpc.CallOption) (*google_protobuf1.Empty, error)
// ListTransactions lists all active leases, returning the full list of // List lists all active leases, returning the full list of
// leases and optionally including the referenced resources. // leases and optionally including the referenced resources.
List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error) List(ctx context.Context, in *ListRequest, opts ...grpc.CallOption) (*ListResponse, error)
} }
@ -183,7 +183,7 @@ type LeasesServer interface {
// during the lease eligible for garbage collection if not referenced // during the lease eligible for garbage collection if not referenced
// or retained by other resources during the lease. // or retained by other resources during the lease.
Delete(context.Context, *DeleteRequest) (*google_protobuf1.Empty, error) Delete(context.Context, *DeleteRequest) (*google_protobuf1.Empty, error)
// ListTransactions lists all active leases, returning the full list of // List lists all active leases, returning the full list of
// leases and optionally including the referenced resources. // leases and optionally including the referenced resources.
List(context.Context, *ListRequest) (*ListResponse, error) List(context.Context, *ListRequest) (*ListResponse, error)
} }

View File

@ -19,7 +19,7 @@ service Leases {
// or retained by other resources during the lease. // or retained by other resources during the lease.
rpc Delete(DeleteRequest) returns (google.protobuf.Empty); rpc Delete(DeleteRequest) returns (google.protobuf.Empty);
// ListTransactions lists all active leases, returning the full list of // List lists all active leases, returning the full list of
// leases and optionally including the referenced resources. // leases and optionally including the referenced resources.
rpc List(ListRequest) returns (ListResponse); rpc List(ListRequest) returns (ListResponse);
} }

View File

@ -1 +0,0 @@
package archive

View File

@ -10,15 +10,6 @@ import (
"github.com/containerd/containerd/sys" "github.com/containerd/containerd/sys"
) )
func getStartTime(fi os.FileInfo) time.Time {
if st, ok := fi.Sys().(*syscall.Stat_t); ok {
return time.Unix(int64(sys.StatCtime(st).Sec),
int64(sys.StatCtime(st).Nsec))
}
return fi.ModTime()
}
func getATime(fi os.FileInfo) time.Time { func getATime(fi os.FileInfo) time.Time {
if st, ok := fi.Sys().(*syscall.Stat_t); ok { if st, ok := fi.Sys().(*syscall.Stat_t); ok {
return time.Unix(int64(sys.StatAtime(st).Sec), return time.Unix(int64(sys.StatAtime(st).Sec),

View File

@ -5,10 +5,6 @@ import (
"time" "time"
) )
func getStartTime(fi os.FileInfo) time.Time {
return fi.ModTime()
}
func getATime(fi os.FileInfo) time.Time { func getATime(fi os.FileInfo) time.Time {
return fi.ModTime() return fi.ModTime()
} }

View File

@ -5,36 +5,12 @@ package fs
import ( import (
"bytes" "bytes"
"os" "os"
"path/filepath"
"strings"
"syscall" "syscall"
"github.com/containerd/continuity/sysx" "github.com/containerd/continuity/sysx"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
// whiteouts are files with a special meaning for the layered filesystem.
// Docker uses AUFS whiteout files inside exported archives. In other
// filesystems these files are generated/handled on tar creation/extraction.
// whiteoutPrefix prefix means file is a whiteout. If this is followed by a
// filename this means that file has been removed from the base layer.
const whiteoutPrefix = ".wh."
// whiteoutMetaPrefix prefix means whiteout has a special meaning and is not
// for removing an actual file. Normally these files are excluded from exported
// archives.
const whiteoutMetaPrefix = whiteoutPrefix + whiteoutPrefix
// whiteoutLinkDir is a directory AUFS uses for storing hardlink links to other
// layers. Normally these should not go into exported archives and all changed
// hardlinks should be copied to the top layer.
const whiteoutLinkDir = whiteoutMetaPrefix + "plnk"
// whiteoutOpaqueDir file means directory has been made opaque - meaning
// readdir calls to this directory do not follow to lower layers.
const whiteoutOpaqueDir = whiteoutMetaPrefix + ".opq"
// detectDirDiff returns diff dir options if a directory could // detectDirDiff returns diff dir options if a directory could
// be found in the mount info for upper which is the direct // be found in the mount info for upper which is the direct
// diff with the provided lower directory // diff with the provided lower directory
@ -45,26 +21,6 @@ func detectDirDiff(upper, lower string) *diffDirOptions {
return nil return nil
} }
func aufsMetadataSkip(path string) (skip bool, err error) {
skip, err = filepath.Match(string(os.PathSeparator)+whiteoutMetaPrefix+"*", path)
if err != nil {
skip = true
}
return
}
func aufsDeletedFile(root, path string, fi os.FileInfo) (string, error) {
f := filepath.Base(path)
// If there is a whiteout, then the file was removed
if strings.HasPrefix(f, whiteoutPrefix) {
originalFile := f[len(whiteoutPrefix):]
return filepath.Join(filepath.Dir(path), originalFile), nil
}
return "", nil
}
// compareSysStat returns whether the stats are equivalent, // compareSysStat returns whether the stats are equivalent,
// whether the files are considered the same file, and // whether the files are considered the same file, and
// an error // an error

View File

@ -74,11 +74,14 @@ func sameFile(f1, f2 *currentPath) (bool, error) {
// If the timestamp may have been truncated in one of the // If the timestamp may have been truncated in one of the
// files, check content of file to determine difference // files, check content of file to determine difference
if t1.Nanosecond() == 0 || t2.Nanosecond() == 0 { if t1.Nanosecond() == 0 || t2.Nanosecond() == 0 {
if f1.f.Size() > 0 { var eq bool
eq, err := compareFileContent(f1.fullPath, f2.fullPath) if (f1.f.Mode() & os.ModeSymlink) == os.ModeSymlink {
if err != nil || !eq { eq, err = compareSymlinkTarget(f1.fullPath, f2.fullPath)
return eq, err } else if f1.f.Size() > 0 {
} eq, err = compareFileContent(f1.fullPath, f2.fullPath)
}
if err != nil || !eq {
return eq, err
} }
} else if t1.Nanosecond() != t2.Nanosecond() { } else if t1.Nanosecond() != t2.Nanosecond() {
return false, nil return false, nil
@ -88,6 +91,18 @@ func sameFile(f1, f2 *currentPath) (bool, error) {
return true, nil return true, nil
} }
func compareSymlinkTarget(p1, p2 string) (bool, error) {
t1, err := os.Readlink(p1)
if err != nil {
return false, err
}
t2, err := os.Readlink(p2)
if err != nil {
return false, err
}
return t1 == t2, nil
}
const compareChuckSize = 32 * 1024 const compareChuckSize = 32 * 1024
// compareFileContent compares the content of 2 same sized files // compareFileContent compares the content of 2 same sized files

View File

@ -36,7 +36,7 @@ func Tricolor(roots []Node, refs func(ref Node) ([]Node, error)) (map[Node]struc
var ( var (
grays []Node // maintain a gray "stack" grays []Node // maintain a gray "stack"
seen = map[Node]struct{}{} // or not "white", basically "seen" seen = map[Node]struct{}{} // or not "white", basically "seen"
reachable = map[Node]struct{}{} // or "block", in tri-color parlance reachable = map[Node]struct{}{} // or "black", in tri-color parlance
) )
grays = append(grays, roots...) grays = append(grays, roots...)

View File

@ -31,7 +31,6 @@ var (
bucketKeyVersion = []byte(schemaVersion) bucketKeyVersion = []byte(schemaVersion)
bucketKeyDBVersion = []byte("version") // stores the version of the schema bucketKeyDBVersion = []byte("version") // stores the version of the schema
bucketKeyObjectLabels = []byte("labels") // stores the labels for a namespace. bucketKeyObjectLabels = []byte("labels") // stores the labels for a namespace.
bucketKeyObjectIndexes = []byte("indexes") // reserved
bucketKeyObjectImages = []byte("images") // stores image objects bucketKeyObjectImages = []byte("images") // stores image objects
bucketKeyObjectContainers = []byte("containers") // stores container objects bucketKeyObjectContainers = []byte("containers") // stores container objects
bucketKeyObjectSnapshots = []byte("snapshots") // stores snapshot references bucketKeyObjectSnapshots = []byte("snapshots") // stores snapshot references

View File

@ -39,14 +39,6 @@ func createKey(id uint64, namespace, key string) string {
return fmt.Sprintf("%s/%d/%s", namespace, id, key) return fmt.Sprintf("%s/%d/%s", namespace, id, key)
} }
func trimKey(key string) string {
parts := strings.SplitN(key, "/", 3)
if len(parts) < 3 {
return ""
}
return parts[2]
}
func getKey(tx *bolt.Tx, ns, name, key string) string { func getKey(tx *bolt.Tx, ns, name, key string) string {
bkt := getSnapshotterBucket(tx, ns, name) bkt := getSnapshotterBucket(tx, ns, name)
if bkt == nil { if bkt == nil {

View File

@ -64,6 +64,9 @@ func (hrs *httpReadSeeker) Seek(offset int64, whence int) (int64, error) {
case io.SeekCurrent: case io.SeekCurrent:
abs += offset abs += offset
case io.SeekEnd: case io.SeekEnd:
if hrs.size == -1 {
return 0, errors.Wrap(errdefs.ErrUnavailable, "Fetcher.Seek: unknown size, cannot seek from end")
}
abs = hrs.size + offset abs = hrs.size + offset
default: default:
return 0, errors.Wrap(errdefs.ErrInvalidArgument, "Fetcher.Seek: invalid whence") return 0, errors.Wrap(errdefs.ErrInvalidArgument, "Fetcher.Seek: invalid whence")
@ -93,7 +96,7 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) {
return hrs.rc, nil return hrs.rc, nil
} }
if hrs.offset < hrs.size { if hrs.size == -1 || hrs.offset < hrs.size {
// only try to reopen the body request if we are seeking to a value // only try to reopen the body request if we are seeking to a value
// less than the actual size. // less than the actual size.
if hrs.open == nil { if hrs.open == nil {

View File

@ -7,7 +7,6 @@ import (
"io" "io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"net/textproto"
"net/url" "net/url"
"path" "path"
"strconv" "strconv"
@ -405,22 +404,6 @@ func copyRequest(req *http.Request) (*http.Request, error) {
return &ireq, nil return &ireq, nil
} }
func isManifestAccept(h http.Header) bool {
for _, ah := range h[textproto.CanonicalMIMEHeaderKey("Accept")] {
switch ah {
case images.MediaTypeDockerSchema2Manifest:
fallthrough
case images.MediaTypeDockerSchema2ManifestList:
fallthrough
case ocispec.MediaTypeImageManifest:
fallthrough
case ocispec.MediaTypeImageIndex:
return true
}
}
return false
}
func (r *dockerBase) setTokenAuth(ctx context.Context, params map[string]string) error { func (r *dockerBase) setTokenAuth(ctx context.Context, params map[string]string) error {
realm, ok := params["realm"] realm, ok := params["realm"]
if !ok { if !ok {

View File

@ -29,10 +29,6 @@ import (
const manifestSizeLimit = 8e6 // 8MB const manifestSizeLimit = 8e6 // 8MB
var (
mediaTypeManifest = "application/vnd.docker.distribution.manifest.v1+json"
)
type blobState struct { type blobState struct {
diffID digest.Digest diffID digest.Digest
empty bool empty bool
@ -87,6 +83,7 @@ func (c *Converter) Handle(ctx context.Context, desc ocispec.Descriptor) ([]ocis
{ {
MediaType: images.MediaTypeDockerSchema2LayerGzip, MediaType: images.MediaTypeDockerSchema2LayerGzip,
Digest: c.pulledManifest.FSLayers[i].BlobSum, Digest: c.pulledManifest.FSLayers[i].BlobSum,
Size: -1,
}, },
}, descs...) }, descs...)
} }
@ -213,10 +210,16 @@ func (c *Converter) fetchBlob(ctx context.Context, desc ocispec.Descriptor) erro
ref = remotes.MakeRefKey(ctx, desc) ref = remotes.MakeRefKey(ctx, desc)
calc = newBlobStateCalculator() calc = newBlobStateCalculator()
retry = 16 retry = 16
size = desc.Size
) )
// size may be unknown, set to zero for content ingest
if size == -1 {
size = 0
}
tryit: tryit:
cw, err := c.contentStore.Writer(ctx, ref, desc.Size, desc.Digest) cw, err := c.contentStore.Writer(ctx, ref, size, desc.Digest)
if err != nil { if err != nil {
if errdefs.IsUnavailable(err) { if errdefs.IsUnavailable(err) {
select { select {
@ -277,7 +280,8 @@ tryit:
eg.Go(func() error { eg.Go(func() error {
defer pw.Close() defer pw.Close()
return content.Copy(ctx, cw, io.TeeReader(rc, pw), desc.Size, desc.Digest)
return content.Copy(ctx, cw, io.TeeReader(rc, pw), size, desc.Digest)
}) })
if err := eg.Wait(); err != nil { if err := eg.Wait(); err != nil {
@ -285,7 +289,7 @@ tryit:
} }
} }
if desc.Size == 0 { if desc.Size == -1 {
info, err := c.contentStore.Info(ctx, desc.Digest) info, err := c.contentStore.Info(ctx, desc.Digest)
if err != nil { if err != nil {
return errors.Wrap(err, "failed to get blob info") return errors.Wrap(err, "failed to get blob info")

View File

@ -38,13 +38,6 @@ type snapshotter struct {
ms *storage.MetaStore ms *storage.MetaStore
} }
type activeSnapshot struct {
id string
name string
parentID interface{}
readonly bool
}
// NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs // NewSnapshotter returns a Snapshotter which uses overlayfs. The overlayfs
// diffs are stored under the provided root. A metadata file is stored under // diffs are stored under the provided root. A metadata file is stored under
// the root. // the root.

View File

@ -8,7 +8,6 @@ import (
"io" "io"
goruntime "runtime" goruntime "runtime"
"strings" "strings"
"sync"
"syscall" "syscall"
"time" "time"
@ -152,8 +151,6 @@ type task struct {
io cio.IO io cio.IO
id string id string
pid uint32 pid uint32
mu sync.Mutex
} }
// Pid returns the pid or process id for the task // Pid returns the pid or process id for the task