Merge pull request #2069 from AkihiroSuda/carry-2001
[Carry 2001] Dockerfile: update containerd to 1.4.3 + fix testutilv0.9
commit
33b56587e9
|
@ -1,7 +1,7 @@
|
|||
# syntax = docker/dockerfile:1.2
|
||||
|
||||
ARG RUNC_VERSION=v1.0.0-rc93
|
||||
ARG CONTAINERD_VERSION=v1.4.2
|
||||
ARG CONTAINERD_VERSION=v1.4.3
|
||||
# containerd v1.3 for integration tests
|
||||
ARG CONTAINERD_ALT_VERSION=v1.3.7
|
||||
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only
|
||||
|
|
|
@ -16,9 +16,8 @@ import (
|
|||
|
||||
func InitContainerdWorker() {
|
||||
Register(&containerd{
|
||||
name: "containerd",
|
||||
containerd: "containerd",
|
||||
containerdShim: "containerd-shim-runc-v2",
|
||||
name: "containerd",
|
||||
containerd: "containerd",
|
||||
})
|
||||
// defined in Dockerfile
|
||||
// e.g. `containerd-1.1=/opt/containerd-1.1/bin,containerd-42.0=/opt/containerd-42.0/bin`
|
||||
|
@ -31,28 +30,28 @@ func InitContainerdWorker() {
|
|||
}
|
||||
name, bin := pair[0], pair[1]
|
||||
Register(&containerd{
|
||||
name: name,
|
||||
containerd: filepath.Join(bin, "containerd"),
|
||||
containerdShim: filepath.Join(bin, "containerd-shim-runc-v2"),
|
||||
name: name,
|
||||
containerd: filepath.Join(bin, "containerd"),
|
||||
// override PATH to make sure that the expected version of the shim binary is used
|
||||
extraEnv: []string{fmt.Sprintf("PATH=%s:%s", bin, os.Getenv("PATH"))},
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if s := os.Getenv("BUILDKIT_INTEGRATION_SNAPSHOTTER"); s != "" {
|
||||
Register(&containerd{
|
||||
name: fmt.Sprintf("containerd-snapshotter-%s", s),
|
||||
containerd: "containerd",
|
||||
containerdShim: "containerd-shim-runc-v2",
|
||||
snapshotter: s,
|
||||
name: fmt.Sprintf("containerd-snapshotter-%s", s),
|
||||
containerd: "containerd",
|
||||
snapshotter: s,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
type containerd struct {
|
||||
name string
|
||||
containerd string
|
||||
containerdShim string
|
||||
snapshotter string
|
||||
name string
|
||||
containerd string
|
||||
snapshotter string
|
||||
extraEnv []string // e.g. "PATH=/opt/containerd-1.4/bin:/usr/bin:..."
|
||||
}
|
||||
|
||||
func (c *containerd) Name() string {
|
||||
|
@ -63,9 +62,6 @@ func (c *containerd) New(cfg *BackendConfig) (b Backend, cl func() error, err er
|
|||
if err := lookupBinary(c.containerd); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if err := lookupBinary(c.containerdShim); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
if err := lookupBinary("buildkitd"); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -103,11 +99,7 @@ disabled_plugins = ["cri"]
|
|||
[debug]
|
||||
level = "debug"
|
||||
address = %q
|
||||
|
||||
[plugins]
|
||||
[plugins.linux]
|
||||
shim = %q
|
||||
`, filepath.Join(tmpdir, "root"), filepath.Join(tmpdir, "state"), address, filepath.Join(tmpdir, "debug.sock"), c.containerdShim)
|
||||
`, filepath.Join(tmpdir, "root"), filepath.Join(tmpdir, "state"), address, filepath.Join(tmpdir, "debug.sock"))
|
||||
|
||||
var snBuildkitdArgs []string
|
||||
if c.snapshotter != "" {
|
||||
|
@ -135,6 +127,7 @@ disabled_plugins = ["cri"]
|
|||
}
|
||||
|
||||
cmd := exec.Command(c.containerd, "--config", configFile)
|
||||
cmd.Env = append(os.Environ(), c.extraEnv...)
|
||||
|
||||
ctdStop, err := startCmd(cmd, cfg.Logs)
|
||||
if err != nil {
|
||||
|
@ -154,7 +147,7 @@ disabled_plugins = ["cri"]
|
|||
"--containerd-worker-labels=org.mobyproject.buildkit.worker.sandbox=true", // Include use of --containerd-worker-labels to trigger https://github.com/moby/buildkit/pull/603
|
||||
}, snBuildkitdArgs...)
|
||||
|
||||
buildkitdSock, stop, err := runBuildkitd(cfg, buildkitdArgs, cfg.Logs, 0, 0)
|
||||
buildkitdSock, stop, err := runBuildkitd(cfg, buildkitdArgs, cfg.Logs, 0, 0, c.extraEnv)
|
||||
if err != nil {
|
||||
printLogs(cfg.Logs, log.Println)
|
||||
return nil, nil, err
|
||||
|
|
|
@ -67,7 +67,7 @@ func (s *oci) New(cfg *BackendConfig) (Backend, func() error, error) {
|
|||
buildkitdArgs = append([]string{"sudo", "-u", fmt.Sprintf("#%d", s.uid), "-i", "--", "exec", "rootlesskit"}, buildkitdArgs...)
|
||||
}
|
||||
|
||||
buildkitdSock, stop, err := runBuildkitd(cfg, buildkitdArgs, cfg.Logs, s.uid, s.gid)
|
||||
buildkitdSock, stop, err := runBuildkitd(cfg, buildkitdArgs, cfg.Logs, s.uid, s.gid, nil)
|
||||
if err != nil {
|
||||
printLogs(cfg.Logs, log.Println)
|
||||
return nil, nil, err
|
||||
|
|
|
@ -139,7 +139,7 @@ func getBuildkitdAddr(tmpdir string) string {
|
|||
return address
|
||||
}
|
||||
|
||||
func runBuildkitd(conf *BackendConfig, args []string, logs map[string]*bytes.Buffer, uid, gid int) (address string, cl func() error, err error) {
|
||||
func runBuildkitd(conf *BackendConfig, args []string, logs map[string]*bytes.Buffer, uid, gid int, extraEnv []string) (address string, cl func() error, err error) {
|
||||
deferF := &multiCloser{}
|
||||
cl = deferF.F()
|
||||
|
||||
|
@ -175,6 +175,7 @@ func runBuildkitd(conf *BackendConfig, args []string, logs map[string]*bytes.Buf
|
|||
args = append(args, "--root", tmpdir, "--addr", address, "--debug")
|
||||
cmd := exec.Command(args[0], args[1:]...)
|
||||
cmd.Env = append(os.Environ(), "BUILDKIT_DEBUG_EXEC_OUTPUT=1", "BUILDKIT_DEBUG_PANIC_ON_ERROR=1", "TMPDIR="+filepath.Join(tmpdir, "tmp"))
|
||||
cmd.Env = append(cmd.Env, extraEnv...)
|
||||
cmd.SysProcAttr = getSysProcAttr()
|
||||
|
||||
stop, err := startCmd(cmd, logs)
|
||||
|
|
Loading…
Reference in New Issue