Merge pull request #587 from AkihiroSuda/update-containerd-113

update containerd (binary: v1.1.3, library: Aug 23, 2018)
docker-18.09
Tõnis Tiigi 2018-08-24 20:29:28 -07:00 committed by GitHub
commit 277037a77f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 73 additions and 34 deletions

View File

@ -232,7 +232,7 @@ export JAEGER_TRACE=0.0.0.0:6831
### 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/v1.1.0/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/v1.1.3/RUNC.md) for more information.
### Running BuildKit without root privileges ### Running BuildKit without root privileges

View File

@ -65,6 +65,10 @@ func TestClientIntegration(t *testing.T) {
}) })
} }
func newContainerd(cdAddress string) (*containerd.Client, error) {
return containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
}
func testExtraHosts(t *testing.T, sb integration.Sandbox) { func testExtraHosts(t *testing.T, sb integration.Sandbox) {
t.Parallel() t.Parallel()
@ -670,7 +674,7 @@ func testBuildPushAndValidate(t *testing.T, sb integration.Sandbox) {
// TODO: make public pull helper function so this can be checked for standalone as well // TODO: make public pull helper function so this can be checked for standalone as well
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -1312,7 +1316,7 @@ loop0:
// TODO: make public pull helper function so this can be checked for standalone as well // TODO: make public pull helper function so this can be checked for standalone as well
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()

View File

@ -9,6 +9,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
"time"
"github.com/containerd/containerd" "github.com/containerd/containerd"
"github.com/containerd/containerd/namespaces" "github.com/containerd/containerd/namespaces"
@ -90,7 +91,7 @@ func testBuildContainerdExporter(t *testing.T, sb integration.Sandbox) {
err = cmd.Run() err = cmd.Run()
require.NoError(t, err) require.NoError(t, err)
client, err := containerd.New(cdAddress) client, err := containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()

View File

@ -5,6 +5,7 @@ package main
import ( import (
"os" "os"
"strings" "strings"
"time"
ctd "github.com/containerd/containerd" ctd "github.com/containerd/containerd"
"github.com/moby/buildkit/worker" "github.com/moby/buildkit/worker"
@ -66,7 +67,7 @@ func containerdWorkerInitializer(c *cli.Context, common workerInitializerOpt) ([
logrus.Warn("rootless mode is not supported for containerd workers. disabling containerd worker.") logrus.Warn("rootless mode is not supported for containerd workers. disabling containerd worker.")
return nil, nil return nil, nil
} }
opt, err := containerd.NewWorkerOpt(common.root, socket, ctd.DefaultSnapshotter, labels) opt, err := containerd.NewWorkerOpt(common.root, socket, ctd.DefaultSnapshotter, labels, ctd.WithTimeout(60*time.Second))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View File

@ -17,7 +17,7 @@ type buildOpt struct {
func main() { func main() {
var opt buildOpt var opt buildOpt
flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker") flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
flag.StringVar(&opt.containerd, "containerd", "v1.1.0", "containerd version") flag.StringVar(&opt.containerd, "containerd", "v1.1.3", "containerd version")
flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "runc version") flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "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.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker") flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
flag.StringVar(&opt.containerd, "containerd", "v1.1.0", "containerd version") flag.StringVar(&opt.containerd, "containerd", "v1.1.3", "containerd version")
flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "runc version") flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "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.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker") flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
flag.StringVar(&opt.containerd, "containerd", "v1.1.0", "containerd version") flag.StringVar(&opt.containerd, "containerd", "v1.1.3", "containerd version")
flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "runc version") flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "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.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker") flag.BoolVar(&opt.withContainerd, "with-containerd", true, "enable containerd worker")
flag.StringVar(&opt.containerd, "containerd", "v1.1.0", "containerd version") flag.StringVar(&opt.containerd, "containerd", "v1.1.3", "containerd version")
flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "runc version") flag.StringVar(&opt.runc, "runc", "dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4", "runc version")
flag.StringVar(&opt.buildkit, "buildkit", "master", "buildkit version") flag.StringVar(&opt.buildkit, "buildkit", "master", "buildkit version")
flag.Parse() flag.Parse()

View File

@ -43,7 +43,7 @@ func run() error {
_ = buildkitd _ = buildkitd
containerd, err := gb.BuildExe(gobuild.BuildOpt{ containerd, err := gb.BuildExe(gobuild.BuildOpt{
Source: llb.Git("github.com/containerd/containerd", "v1.1.0"), Source: llb.Git("github.com/containerd/containerd", "v1.1.3"),
MountPath: "/go/src/github.com/containerd/containerd", MountPath: "/go/src/github.com/containerd/containerd",
Pkg: "github.com/containerd/containerd/cmd/containerd", Pkg: "github.com/containerd/containerd/cmd/containerd",
BuildTags: []string{"no_btrfs"}, BuildTags: []string{"no_btrfs"},

View File

@ -77,6 +77,10 @@ func TestIntegration(t *testing.T) {
}) })
} }
func newContainerd(cdAddress string) (*containerd.Client, error) {
return containerd.New(cdAddress, containerd.WithTimeout(60*time.Second))
}
func testExportMultiPlatform(t *testing.T, sb integration.Sandbox) { func testExportMultiPlatform(t *testing.T, sb integration.Sandbox) {
t.Parallel() t.Parallel()
@ -470,7 +474,7 @@ ENTRYPOINT my entrypoint
}, nil) }, nil)
require.NoError(t, err) require.NoError(t, err)
ctr, err := containerd.New(cdAddress) ctr, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer ctr.Close() defer ctr.Close()
@ -561,7 +565,7 @@ COPY foo .
}, nil) }, nil)
require.NoError(t, err) require.NoError(t, err)
ctr, err := containerd.New(cdAddress) ctr, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer ctr.Close() defer ctr.Close()
@ -1060,7 +1064,7 @@ ENV foo=bar
err = cmd.Run() err = cmd.Run()
require.NoError(t, err) require.NoError(t, err)
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -1143,7 +1147,7 @@ EXPOSE 5000
cdAddress = cd.ContainerdAddress() cdAddress = cd.ContainerdAddress()
} }
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -1324,7 +1328,7 @@ RUN ["ls"]
cdAddress = cd.ContainerdAddress() cdAddress = cd.ContainerdAddress()
} }
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -1482,7 +1486,7 @@ USER nobody
cdAddress = cd.ContainerdAddress() cdAddress = cd.ContainerdAddress()
} }
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -2055,7 +2059,7 @@ LABEL foo=bar
cdAddress = cd.ContainerdAddress() cdAddress = cd.ContainerdAddress()
} }
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -2230,7 +2234,7 @@ RUN echo bar > bar
cdAddress = cd.ContainerdAddress() cdAddress = cd.ContainerdAddress()
} }
client, err := containerd.New(cdAddress) client, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer client.Close() defer client.Close()
@ -2300,7 +2304,7 @@ RUN echo bar > bar
}, },
} }
ctd, err := containerd.New(cdAddress) ctd, err := newContainerd(cdAddress)
require.NoError(t, err) require.NoError(t, err)
defer ctd.Close() defer ctd.Close()

View File

@ -1,5 +1,5 @@
ARG RUNC_VERSION=dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4 ARG RUNC_VERSION=dd56ece8236d6d9e5bed4ea0c31fe53c7b873ff4
ARG CONTAINERD_VERSION=v1.1.0 ARG CONTAINERD_VERSION=v1.1.3
# containerd v1.0 for integration tests # containerd v1.0 for integration tests
ARG CONTAINERD10_VERSION=v1.0.3 ARG CONTAINERD10_VERSION=v1.0.3
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only # available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only

View File

@ -82,6 +82,9 @@ func (c *containerd) New() (sb Sandbox, cl func() error, err error) {
address := filepath.Join(tmpdir, "containerd.sock") address := filepath.Join(tmpdir, "containerd.sock")
config := fmt.Sprintf(`root = %q config := fmt.Sprintf(`root = %q
state = %q state = %q
# CRI plugins listens on 10010/tcp for stream server.
# We disable CRI plugin so that multiple instance can run simultaneously.
disabled_plugins = ["cri"]
[grpc] [grpc]
address = %q address = %q
@ -102,14 +105,15 @@ state = %q
logs := map[string]*bytes.Buffer{} logs := map[string]*bytes.Buffer{}
if stop, err := startCmd(cmd, logs); err != nil { ctdStop, err := startCmd(cmd, logs)
if err != nil {
return nil, nil, err return nil, nil, err
} else {
deferF.append(stop)
} }
if err := waitUnix(address, 5*time.Second); err != nil { if err := waitUnix(address, 5*time.Second); err != nil {
return nil, nil, err ctdStop()
return nil, nil, errors.Wrapf(err, "containerd did not start up: %s", formatLogs(logs))
} }
deferF.append(ctdStop)
buildkitdSock, stop, err := runBuildkitd([]string{"buildkitd", buildkitdSock, stop, err := runBuildkitd([]string{"buildkitd",
"--oci-worker=false", "--oci-worker=false",
@ -123,6 +127,16 @@ state = %q
return &cdsandbox{address: address, sandbox: sandbox{address: buildkitdSock, logs: logs, cleanup: deferF, rootless: false}}, cl, nil return &cdsandbox{address: address, sandbox: sandbox{address: buildkitdSock, logs: logs, cleanup: deferF, rootless: false}}, cl, nil
} }
func formatLogs(m map[string]*bytes.Buffer) string {
var ss []string
for k, b := range m {
if b != nil {
ss = append(ss, fmt.Sprintf("%q:%q", k, b.String()))
}
}
return strings.Join(ss, ",")
}
type cdsandbox struct { type cdsandbox struct {
sandbox sandbox
address string address string

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 1b2967e3c290b7c545b3db0deeda16e9be4f98a2 golang.org/x/sys 1b2967e3c290b7c545b3db0deeda16e9be4f98a2
github.com/containerd/containerd v1.2.0-beta.0 github.com/containerd/containerd 830363acac529947d794b50c3eec3bc47c59a183
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40 github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
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

@ -259,7 +259,7 @@ func fileInfoFromHeader(hdr *tar.Header) (name string, size int64, fileInfo *win
if err != nil { if err != nil {
return "", 0, nil, err return "", 0, nil, err
} }
fileInfo.FileAttributes = uintptr(attr) fileInfo.FileAttributes = uint32(attr)
} else { } else {
if hdr.Typeflag == tar.TypeDir { if hdr.Typeflag == tar.TypeDir {
fileInfo.FileAttributes |= syscall.FILE_ATTRIBUTE_DIRECTORY fileInfo.FileAttributes |= syscall.FILE_ATTRIBUTE_DIRECTORY

View File

@ -74,7 +74,7 @@ func copyIO(fifos *FIFOSet, ioset *Streams) (*cio, error) {
if fifos.Stdout != "" { if fifos.Stdout != "" {
l, err := winio.ListenPipe(fifos.Stdout, nil) l, err := winio.ListenPipe(fifos.Stdout, nil)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "failed to create stdin pipe %s", fifos.Stdout) return nil, errors.Wrapf(err, "failed to create stdout pipe %s", fifos.Stdout)
} }
defer func(l net.Listener) { defer func(l net.Listener) {
if err != nil { if err != nil {
@ -99,7 +99,7 @@ func copyIO(fifos *FIFOSet, ioset *Streams) (*cio, error) {
}() }()
} }
if !fifos.Terminal && fifos.Stderr != "" { if fifos.Stderr != "" {
l, err := winio.ListenPipe(fifos.Stderr, nil) l, err := winio.ListenPipe(fifos.Stderr, nil)
if err != nil { if err != nil {
return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.Stderr) return nil, errors.Wrapf(err, "failed to create stderr pipe %s", fifos.Stderr)

View File

@ -82,6 +82,9 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
return nil, err return nil, err
} }
} }
if copts.timeout == 0 {
copts.timeout = 10 * time.Second
}
rt := fmt.Sprintf("%s.%s", plugin.RuntimePlugin, runtime.GOOS) rt := fmt.Sprintf("%s.%s", plugin.RuntimePlugin, runtime.GOOS)
if copts.defaultRuntime != "" { if copts.defaultRuntime != "" {
rt = copts.defaultRuntime rt = copts.defaultRuntime
@ -115,7 +118,7 @@ func New(address string, opts ...ClientOpt) (*Client, error) {
) )
} }
connector := func() (*grpc.ClientConn, error) { connector := func() (*grpc.ClientConn, error) {
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) ctx, cancel := context.WithTimeout(context.Background(), copts.timeout)
defer cancel() defer cancel()
conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...) conn, err := grpc.DialContext(ctx, dialer.DialAddress(address), gopts...)
if err != nil { if err != nil {

View File

@ -17,6 +17,8 @@
package containerd package containerd
import ( import (
"time"
"github.com/containerd/containerd/images" "github.com/containerd/containerd/images"
"github.com/containerd/containerd/platforms" "github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/remotes" "github.com/containerd/containerd/remotes"
@ -28,6 +30,7 @@ type clientOpts struct {
defaultRuntime string defaultRuntime string
services *services services *services
dialOptions []grpc.DialOption dialOptions []grpc.DialOption
timeout time.Duration
} }
// ClientOpt allows callers to set options on the containerd client // ClientOpt allows callers to set options on the containerd client
@ -71,6 +74,14 @@ func WithServices(opts ...ServicesOpt) ClientOpt {
} }
} }
// WithTimeout sets the connection timeout for the client
func WithTimeout(d time.Duration) ClientOpt {
return func(c *clientOpts) error {
c.timeout = d
return nil
}
}
// RemoteOpt allows the caller to set distribution options for a remote // RemoteOpt allows the caller to set distribution options for a remote
type RemoteOpt func(*Client, *RemoteContext) error type RemoteOpt func(*Client, *RemoteContext) error

View File

@ -143,6 +143,7 @@ func WithImageConfigArgs(image Image, args []string) SpecOpts {
cmd = args cmd = args
} }
s.Process.Args = append(config.Entrypoint, cmd...) s.Process.Args = append(config.Entrypoint, cmd...)
cwd := config.WorkingDir cwd := config.WorkingDir
if cwd == "" { if cwd == "" {
cwd = "/" cwd = "/"

View File

@ -1,5 +1,5 @@
github.com/containerd/go-runc edcf3de1f4971445c42d61f20d506b30612aa031 github.com/containerd/go-runc 808e8444ac4633a8e5eb7314fc6b5d27051727dd
github.com/containerd/console 4d8a41f4ce5b9bae77c41786ea2458330f43f081 github.com/containerd/console c12b1e7919c14469339a5d38f2f8ed9b64a9de23
github.com/containerd/cgroups 5e610833b72089b37d0e615de9a92dfc043757c2 github.com/containerd/cgroups 5e610833b72089b37d0e615de9a92dfc043757c2
github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40 github.com/containerd/typeurl a93fcdb778cd272c6e9b3028b2f42d813e785d40
github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c github.com/containerd/fifo 3d5202aec260678c48179c56f40e6f38a095738c
@ -20,7 +20,7 @@ github.com/gogo/protobuf v1.0.0
github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef github.com/gogo/googleapis 08a7655d27152912db7aaf4f983275eaf8d128ef
github.com/golang/protobuf v1.1.0 github.com/golang/protobuf v1.1.0
github.com/opencontainers/runtime-spec d810dbc60d8c5aeeb3d054bd1132fab2121968ce # v1.0.1-43-gd810dbc github.com/opencontainers/runtime-spec d810dbc60d8c5aeeb3d054bd1132fab2121968ce # v1.0.1-43-gd810dbc
github.com/opencontainers/runc 69663f0bd4b60df09991c08812a60108003fa340 github.com/opencontainers/runc 20aff4f0488c6d4b8df4d85b4f63f1f704c11abd
github.com/sirupsen/logrus v1.0.0 github.com/sirupsen/logrus v1.0.0
github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c github.com/urfave/cli 7bc6a0acffa589f415f88aca16cc1de5ffd66f9c
golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac golang.org/x/net b3756b4b77d7b13260a0a2ec658753cf48922eac
@ -32,8 +32,8 @@ github.com/opencontainers/image-spec v1.0.1
golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c golang.org/x/sync 450f422ab23cf9881c94e2db30cac0eb1b7cf80c
github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895 github.com/BurntSushi/toml a368813c5e648fee92e5f6c30e3944ff9d5e8895
github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0 github.com/grpc-ecosystem/go-grpc-prometheus 6b7015e65d366bf3f19b2b2a000a831940f0f7e0
github.com/Microsoft/go-winio v0.4.7 github.com/Microsoft/go-winio v0.4.10
github.com/Microsoft/hcsshim v0.6.11 github.com/Microsoft/hcsshim 44c060121b68e8bdc40b411beba551f3b4ee9e55
github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd github.com/boltdb/bolt e9cf4fae01b5a8ff89d0ec6b32f0d9c9f79aefdd
google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944 google.golang.org/genproto d80a6e20e776b0b17a324d0ba1ab50a39c8e8944
golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4