Merge pull request #2069 from AkihiroSuda/carry-2001

[Carry 2001] Dockerfile: update containerd to 1.4.3  + fix testutil
v0.9
Tõnis Tiigi 2021-04-09 10:42:42 -07:00 committed by GitHub
commit 33b56587e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 26 deletions

View File

@ -1,7 +1,7 @@
# syntax = docker/dockerfile:1.2 # syntax = docker/dockerfile:1.2
ARG RUNC_VERSION=v1.0.0-rc93 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 # containerd v1.3 for integration tests
ARG CONTAINERD_ALT_VERSION=v1.3.7 ARG CONTAINERD_ALT_VERSION=v1.3.7
# available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only # available targets: buildkitd, buildkitd.oci_only, buildkitd.containerd_only

View File

@ -18,7 +18,6 @@ func InitContainerdWorker() {
Register(&containerd{ Register(&containerd{
name: "containerd", name: "containerd",
containerd: "containerd", containerd: "containerd",
containerdShim: "containerd-shim-runc-v2",
}) })
// defined in Dockerfile // defined in Dockerfile
// e.g. `containerd-1.1=/opt/containerd-1.1/bin,containerd-42.0=/opt/containerd-42.0/bin` // e.g. `containerd-1.1=/opt/containerd-1.1/bin,containerd-42.0=/opt/containerd-42.0/bin`
@ -33,7 +32,8 @@ func InitContainerdWorker() {
Register(&containerd{ Register(&containerd{
name: name, name: name,
containerd: filepath.Join(bin, "containerd"), containerd: filepath.Join(bin, "containerd"),
containerdShim: filepath.Join(bin, "containerd-shim-runc-v2"), // 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"))},
}) })
} }
} }
@ -42,7 +42,6 @@ func InitContainerdWorker() {
Register(&containerd{ Register(&containerd{
name: fmt.Sprintf("containerd-snapshotter-%s", s), name: fmt.Sprintf("containerd-snapshotter-%s", s),
containerd: "containerd", containerd: "containerd",
containerdShim: "containerd-shim-runc-v2",
snapshotter: s, snapshotter: s,
}) })
} }
@ -51,8 +50,8 @@ func InitContainerdWorker() {
type containerd struct { type containerd struct {
name string name string
containerd string containerd string
containerdShim string
snapshotter string snapshotter string
extraEnv []string // e.g. "PATH=/opt/containerd-1.4/bin:/usr/bin:..."
} }
func (c *containerd) Name() string { 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 { if err := lookupBinary(c.containerd); err != nil {
return nil, nil, err return nil, nil, err
} }
if err := lookupBinary(c.containerdShim); err != nil {
return nil, nil, err
}
if err := lookupBinary("buildkitd"); err != nil { if err := lookupBinary("buildkitd"); err != nil {
return nil, nil, err return nil, nil, err
} }
@ -103,11 +99,7 @@ disabled_plugins = ["cri"]
[debug] [debug]
level = "debug" level = "debug"
address = %q address = %q
`, filepath.Join(tmpdir, "root"), filepath.Join(tmpdir, "state"), address, filepath.Join(tmpdir, "debug.sock"))
[plugins]
[plugins.linux]
shim = %q
`, filepath.Join(tmpdir, "root"), filepath.Join(tmpdir, "state"), address, filepath.Join(tmpdir, "debug.sock"), c.containerdShim)
var snBuildkitdArgs []string var snBuildkitdArgs []string
if c.snapshotter != "" { if c.snapshotter != "" {
@ -135,6 +127,7 @@ disabled_plugins = ["cri"]
} }
cmd := exec.Command(c.containerd, "--config", configFile) cmd := exec.Command(c.containerd, "--config", configFile)
cmd.Env = append(os.Environ(), c.extraEnv...)
ctdStop, err := startCmd(cmd, cfg.Logs) ctdStop, err := startCmd(cmd, cfg.Logs)
if err != nil { 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 "--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...) }, 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 { if err != nil {
printLogs(cfg.Logs, log.Println) printLogs(cfg.Logs, log.Println)
return nil, nil, err return nil, nil, err

View File

@ -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...) 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 { if err != nil {
printLogs(cfg.Logs, log.Println) printLogs(cfg.Logs, log.Println)
return nil, nil, err return nil, nil, err

View File

@ -139,7 +139,7 @@ func getBuildkitdAddr(tmpdir string) string {
return address 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{} deferF := &multiCloser{}
cl = deferF.F() 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") args = append(args, "--root", tmpdir, "--addr", address, "--debug")
cmd := exec.Command(args[0], args[1:]...) 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(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() cmd.SysProcAttr = getSysProcAttr()
stop, err := startCmd(cmd, logs) stop, err := startCmd(cmd, logs)