diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 19f541e44..0bffbdf5b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -390,16 +390,9 @@ jobs: fail-fast: false matrix: runtime: - - io.containerd.runtime.v1.linux - - io.containerd.runc.v1 - io.containerd.runc.v2 runc: [runc, crun] enable_cri_sandboxes: ["", "sandboxed"] - exclude: - - runtime: io.containerd.runc.v1 - runc: crun - - runtime: io.containerd.runtime.v1.linux - runc: crun env: GOTEST: gotestsum -- diff --git a/Makefile b/Makefile index 02a8aa202..ee42d7c48 100644 --- a/Makefile +++ b/Makefile @@ -254,14 +254,6 @@ bin/gen-manpages: cmd/gen-manpages FORCE @echo "$(WHALE) $@" $(GO) build ${DEBUG_GO_GCFLAGS} ${GO_GCFLAGS} ${GO_BUILD_FLAGS} -o $@ ${GO_LDFLAGS} $(subst urfave_cli_no_docs,,${GO_TAGS}) ./cmd/gen-manpages -bin/containerd-shim: cmd/containerd-shim FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220 - @echo "$(WHALE) $@" - @CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim - -bin/containerd-shim-runc-v1: cmd/containerd-shim-runc-v1 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220 - @echo "$(WHALE) $@" - @CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runc-v1 - bin/containerd-shim-runc-v2: cmd/containerd-shim-runc-v2 FORCE # set !cgo and omit pie for a static shim build: https://github.com/golang/go/issues/17789#issuecomment-258542220 @echo "$(WHALE) $@" @CGO_ENABLED=${SHIM_CGO_ENABLED} $(GO) build ${GO_BUILD_FLAGS} -o $@ ${SHIM_GO_LDFLAGS} ${GO_TAGS} ./cmd/containerd-shim-runc-v2 @@ -400,7 +392,7 @@ clean: ## clean up binaries clean-test: ## clean up debris from previously failed tests @echo "$(WHALE) $@" $(eval containers=$(shell find /run/containerd/runc -mindepth 2 -maxdepth 3 -type d -exec basename {} \;)) - $(shell pidof containerd containerd-shim runc | xargs -r -n 1 kill -9) + $(shell pidof containerd runc | xargs -r -n 1 kill -9) @( for container in $(containers); do \ grep $$container /proc/self/mountinfo | while read -r mountpoint; do \ umount $$(echo $$mountpoint | awk '{print $$5}'); \ diff --git a/Makefile.darwin b/Makefile.darwin index 5303ca40a..4a12e88f2 100644 --- a/Makefile.darwin +++ b/Makefile.darwin @@ -13,9 +13,6 @@ # limitations under the License. -#darwin specific settings -COMMANDS += containerd-shim - # amd64 supports go test -race ifeq ($(GOARCH),amd64) TESTFLAGS_RACE= -race diff --git a/Makefile.freebsd b/Makefile.freebsd index 78e7f2de4..a32c3f752 100644 --- a/Makefile.freebsd +++ b/Makefile.freebsd @@ -14,7 +14,6 @@ #freebsd specific settings -COMMANDS += containerd-shim # amd64 supports go test -race ifeq ($(GOARCH),amd64) diff --git a/Makefile.linux b/Makefile.linux index 054140070..1616b3a0c 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -16,7 +16,7 @@ #linux specific settings WHALE="+" ONI="-" -COMMANDS += containerd-shim containerd-shim-runc-v1 containerd-shim-runc-v2 +COMMANDS += containerd-shim-runc-v2 # check GOOS for cross compile builds ifeq ($(GOOS),linux) diff --git a/Protobuild.toml b/Protobuild.toml index 09a4c9704..e35f99293 100644 --- a/Protobuild.toml +++ b/Protobuild.toml @@ -28,14 +28,6 @@ prefixes = [ ] generators = ["go", "go-grpc"] -# Lock down runc config -[[descriptors]] -prefix = "github.com/containerd/containerd/runtime/linux/runctypes" -target = "runtime/linux/runctypes/next.pb.txt" -ignore_files = [ - "google/protobuf/descriptor.proto", -] - [[descriptors]] prefix = "github.com/containerd/containerd/runtime/v2/runc/options" target = "runtime/v2/runc/options/next.pb.txt" diff --git a/RELEASES.md b/RELEASES.md index b6f926ce9..3860eae52 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -371,8 +371,8 @@ The deprecated features are shown in the following table: | Component | Deprecation release | Target release for removal | Recommendation | |----------------------------------------------------------------------------------|---------------------|----------------------------|------------------------------------------| -| Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 | Use `io.containerd.runc.v2` | -| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 | Use `io.containerd.runc.v2` | +| Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 ✅ | Use `io.containerd.runc.v2` | +| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 ✅ | Use `io.containerd.runc.v2` | | config.toml `version = 1` | containerd v1.5 | containerd v2.0 | Use config.toml `version = 2` | | Built-in `aufs` snapshotter | containerd v1.5 | containerd v2.0 ✅ | Use `overlayfs` snapshotter | | Container label `containerd.io/restart.logpath` | containerd v1.5 | containerd v2.0 ✅ | Use `containerd.io/restart.loguri` label | @@ -385,12 +385,12 @@ The deprecated properties in [`config.toml`](./docs/cri/config.md) are shown in | Property Group | Property | Deprecation release | Target release for removal | Recommendation | |----------------------------------------------------------------------|------------------------------|---------------------|----------------------------|-------------------------------------------------| -|`[plugins."io.containerd.grpc.v1.cri"]` | `systemd_cgroup` | containerd v1.3 | containerd v2.0 | Use `SystemdCgroup` in runc options (see below) | +|`[plugins."io.containerd.grpc.v1.cri"]` | `systemd_cgroup` | containerd v1.3 | containerd v2.0 ✅ | Use `SystemdCgroup` in runc options (see below) | |`[plugins."io.containerd.grpc.v1.cri".cni]` | `conf_template` | containerd v1.? | containerd v2.0 | Create a CNI config in `/etc/cni/net.d` | -|`[plugins."io.containerd.grpc.v1.cri".containerd]` | `untrusted_workload_runtime` | containerd v1.2 | containerd v2.0 | Create `untrusted` runtime in `runtimes` | -|`[plugins."io.containerd.grpc.v1.cri".containerd]` | `default_runtime` | containerd v1.3 | containerd v2.0 | Use `default_runtime_name` | -|`[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.*]` | `runtime_engine` | containerd v1.3 | containerd v2.0 | Use runtime v2 | -|`[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.*]` | `runtime_root` | containerd v1.3 | containerd v2.0 | Use `options.Root` | +|`[plugins."io.containerd.grpc.v1.cri".containerd]` | `untrusted_workload_runtime` | containerd v1.2 | containerd v2.0 ✅ | Create `untrusted` runtime in `runtimes` | +|`[plugins."io.containerd.grpc.v1.cri".containerd]` | `default_runtime` | containerd v1.3 | containerd v2.0 ✅ | Use `default_runtime_name` | +|`[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.*]` | `runtime_engine` | containerd v1.3 | containerd v2.0 ✅ | Use runtime v2 | +|`[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.*]` | `runtime_root` | containerd v1.3 | containerd v2.0 ✅ | Use `options.Root` | |`[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.*.options]` | `CriuPath` | containerd v1.7 | containerd v2.0 | Set `$PATH` to the `criu` binary | |`[plugins."io.containerd.grpc.v1.cri".registry]` | `auths` | containerd v1.3 | containerd v2.0 | Use [`ImagePullSecrets`](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/). See also [#8228](https://github.com/containerd/containerd/issues/8228). | |`[plugins."io.containerd.grpc.v1.cri".registry]` | `configs` | containerd v1.5 | containerd v2.0 | Use [`config_path`](./docs/hosts.md) | diff --git a/client.go b/client.go index a62217b96..c15de8378 100644 --- a/client.go +++ b/client.go @@ -818,23 +818,6 @@ func (c *Client) getSnapshotter(ctx context.Context, name string) (snapshots.Sna return s, nil } -// CheckRuntime returns true if the current runtime matches the expected -// runtime. Providing various parts of the runtime schema will match those -// parts of the expected runtime -func CheckRuntime(current, expected string) bool { - cp := strings.Split(current, ".") - l := len(cp) - for i, p := range strings.Split(expected, ".") { - if i > l { - return false - } - if p != cp[i] { - return false - } - } - return true -} - // GetSnapshotterSupportedPlatforms returns a platform matchers which represents the // supported platforms for the given snapshotters func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error) { diff --git a/cmd/containerd-shim-runc-v1/main.go b/cmd/containerd-shim-runc-v1/main.go deleted file mode 100644 index 4843c3ae6..000000000 --- a/cmd/containerd-shim-runc-v1/main.go +++ /dev/null @@ -1,28 +0,0 @@ -//go:build linux - -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package main - -import ( - v1 "github.com/containerd/containerd/runtime/v2/runc/v1" - "github.com/containerd/containerd/runtime/v2/shim" -) - -func main() { - shim.Run("io.containerd.runc.v1", v1.New) -} diff --git a/cmd/containerd-shim/main_unix.go b/cmd/containerd-shim/main_unix.go deleted file mode 100644 index 94a9f0ca4..000000000 --- a/cmd/containerd-shim/main_unix.go +++ /dev/null @@ -1,333 +0,0 @@ -//go:build !windows - -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package main - -import ( - "bytes" - "context" - "errors" - "flag" - "fmt" - "io" - "net" - "os" - "os/signal" - "runtime" - "runtime/debug" - "strings" - "sync" - "syscall" - "time" - - "github.com/containerd/containerd/events" - "github.com/containerd/containerd/namespaces" - "github.com/containerd/containerd/pkg/process" - "github.com/containerd/containerd/protobuf" - "github.com/containerd/containerd/protobuf/proto" - ptypes "github.com/containerd/containerd/protobuf/types" - shimlog "github.com/containerd/containerd/runtime/v1" - "github.com/containerd/containerd/runtime/v1/shim" - shimapi "github.com/containerd/containerd/runtime/v1/shim/v1" - "github.com/containerd/containerd/sys/reaper" - "github.com/containerd/containerd/version" - "github.com/containerd/ttrpc" - "github.com/sirupsen/logrus" - exec "golang.org/x/sys/execabs" - "golang.org/x/sys/unix" -) - -var ( - debugFlag bool - versionFlag bool - namespaceFlag string - socketFlag string - addressFlag string - workdirFlag string - runtimeRootFlag string - criuFlag string - systemdCgroupFlag bool - containerdBinaryFlag string - - bufPool = sync.Pool{ - New: func() interface{} { - return bytes.NewBuffer(nil) - }, - } -) - -func parseFlags() { - flag.BoolVar(&debugFlag, "debug", false, "enable debug output in logs") - flag.BoolVar(&versionFlag, "v", false, "show the shim version and exit") - flag.StringVar(&namespaceFlag, "namespace", "", "namespace that owns the shim") - flag.StringVar(&socketFlag, "socket", "", "socket path to serve") - flag.StringVar(&addressFlag, "address", "", "grpc address back to main containerd") - flag.StringVar(&workdirFlag, "workdir", "", "path used to storage large temporary data") - flag.StringVar(&runtimeRootFlag, "runtime-root", process.RuncRoot, "root directory for the runtime") - flag.StringVar(&criuFlag, "criu", "", "path to criu binary (deprecated: do not use)") - flag.BoolVar(&systemdCgroupFlag, "systemd-cgroup", false, "set runtime to use systemd-cgroup") - // currently, the `containerd publish` utility is embedded in the daemon binary. - // The daemon invokes `containerd-shim -containerd-binary ...` with its own os.Executable() path. - flag.StringVar(&containerdBinaryFlag, "containerd-binary", "containerd", "path to containerd binary (used for `containerd publish`)") - flag.Parse() -} - -func setRuntime() { - debug.SetGCPercent(40) - go func() { - for range time.Tick(30 * time.Second) { - debug.FreeOSMemory() - } - }() - if os.Getenv("GOMAXPROCS") == "" { - // If GOMAXPROCS hasn't been set, we default to a value of 2 to reduce - // the number of Go stacks present in the shim. - runtime.GOMAXPROCS(2) - } -} - -func main() { - parseFlags() - if versionFlag { - fmt.Println("containerd-shim") - fmt.Println(" Version: ", version.Version) - fmt.Println(" Revision:", version.Revision) - fmt.Println(" Go version:", version.GoVersion) - fmt.Println("") - return - } - - setRuntime() - - if debugFlag { - logrus.SetLevel(logrus.DebugLevel) - } - - stdout, stderr, err := openStdioKeepAlivePipes(workdirFlag) - if err != nil { - fmt.Fprintf(os.Stderr, "containerd-shim: %s\n", err) - os.Exit(1) - } - defer func() { - stdout.Close() - stderr.Close() - }() - - // redirect the following output into fifo to make sure that containerd - // still can read the log after restart - logrus.SetOutput(stdout) - - if err := executeShim(); err != nil { - fmt.Fprintf(os.Stderr, "containerd-shim: %s\n", err) - os.Exit(1) - } -} - -// If containerd server process dies, we need the shim to keep stdout/err reader -// FDs so that Linux does not SIGPIPE the shim process if it tries to use its end of -// these pipes. -func openStdioKeepAlivePipes(dir string) (io.ReadWriteCloser, io.ReadWriteCloser, error) { - background := context.Background() - keepStdoutAlive, err := shimlog.OpenShimStdoutLog(background, dir) - if err != nil { - return nil, nil, err - } - keepStderrAlive, err := shimlog.OpenShimStderrLog(background, dir) - if err != nil { - return nil, nil, err - } - return keepStdoutAlive, keepStderrAlive, nil -} - -func executeShim() error { - // start handling signals as soon as possible so that things are properly reaped - // or if runtime exits before we hit the handler - signals, err := setupSignals() - if err != nil { - return err - } - dump := make(chan os.Signal, 32) - signal.Notify(dump, syscall.SIGUSR1) - - path, err := os.Getwd() - if err != nil { - return err - } - server, err := newServer() - if err != nil { - return fmt.Errorf("failed creating server: %w", err) - } - sv, err := shim.NewService( - shim.Config{ - Path: path, - Namespace: namespaceFlag, - WorkDir: workdirFlag, - SystemdCgroup: systemdCgroupFlag, - RuntimeRoot: runtimeRootFlag, - }, - &remoteEventsPublisher{address: addressFlag}, - ) - if err != nil { - return err - } - logrus.Debug("registering ttrpc server") - shimapi.RegisterShimService(server, sv) - - socket := socketFlag - if err := serve(context.Background(), server, socket); err != nil { - return err - } - logger := logrus.WithFields(logrus.Fields{ - "pid": os.Getpid(), - "path": path, - "namespace": namespaceFlag, - }) - go func() { - for range dump { - dumpStacks(logger) - } - }() - return handleSignals(logger, signals, server, sv) -} - -// serve serves the ttrpc API over a unix socket at the provided path -// this function does not block -func serve(ctx context.Context, server *ttrpc.Server, path string) error { - var ( - l net.Listener - err error - ) - if path == "" { - f := os.NewFile(3, "socket") - l, err = net.FileListener(f) - f.Close() - path = "[inherited from parent]" - } else { - const ( - abstractSocketPrefix = "\x00" - socketPathLimit = 106 - ) - p := strings.TrimPrefix(path, "unix://") - if len(p) == len(path) { - p = abstractSocketPrefix + p - } - if len(p) > socketPathLimit { - return fmt.Errorf("%q: unix socket path too long (> %d)", p, socketPathLimit) - } - l, err = net.Listen("unix", p) - } - if err != nil { - return err - } - logrus.WithField("socket", path).Debug("serving api on unix socket") - go func() { - defer l.Close() - if err := server.Serve(ctx, l); err != nil && !errors.Is(err, net.ErrClosed) { - logrus.WithError(err).Fatal("containerd-shim: ttrpc server failure") - } - }() - return nil -} - -func handleSignals(logger *logrus.Entry, signals chan os.Signal, server *ttrpc.Server, sv *shim.Service) error { - var ( - termOnce sync.Once - done = make(chan struct{}) - ) - - for { - select { - case <-done: - return nil - case s := <-signals: - switch s { - case unix.SIGCHLD: - if err := reaper.Reap(); err != nil { - logger.WithError(err).Error("reap exit status") - } - case unix.SIGTERM, unix.SIGINT: - go termOnce.Do(func() { - ctx := context.TODO() - if err := server.Shutdown(ctx); err != nil { - logger.WithError(err).Error("failed to shutdown server") - } - // Ensure our child is dead if any - sv.Kill(ctx, &shimapi.KillRequest{ - Signal: uint32(syscall.SIGKILL), - All: true, - }) - sv.Delete(context.Background(), &ptypes.Empty{}) - close(done) - }) - case unix.SIGPIPE: - } - } - } -} - -func dumpStacks(logger *logrus.Entry) { - var ( - buf []byte - stackSize int - ) - bufferLen := 16384 - for stackSize == len(buf) { - buf = make([]byte, bufferLen) - stackSize = runtime.Stack(buf, true) - bufferLen *= 2 - } - buf = buf[:stackSize] - logger.Infof("=== BEGIN goroutine stack dump ===\n%s\n=== END goroutine stack dump ===", buf) -} - -type remoteEventsPublisher struct { - address string -} - -func (l *remoteEventsPublisher) Publish(ctx context.Context, topic string, event events.Event) error { - ns, _ := namespaces.Namespace(ctx) - encoded, err := protobuf.MarshalAnyToProto(event) - if err != nil { - return err - } - data, err := proto.Marshal(encoded) - if err != nil { - return err - } - cmd := exec.CommandContext(ctx, containerdBinaryFlag, "--address", l.address, "publish", "--topic", topic, "--namespace", ns) - cmd.Stdin = bytes.NewReader(data) - b := bufPool.Get().(*bytes.Buffer) - defer func() { - b.Reset() - bufPool.Put(b) - }() - cmd.Stdout = b - cmd.Stderr = b - c, err := reaper.Default.Start(cmd) - if err != nil { - return err - } - status, err := reaper.Default.WaitTimeout(cmd, c, 30*time.Second) - if err != nil { - return fmt.Errorf("failed to publish event: %s: %w", b.String(), err) - } - if status != 0 { - return fmt.Errorf("failed to publish event: %s", b.String()) - } - return nil -} diff --git a/cmd/containerd-shim/shim_darwin.go b/cmd/containerd-shim/shim_darwin.go deleted file mode 100644 index 7d652daa1..000000000 --- a/cmd/containerd-shim/shim_darwin.go +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package main - -import ( - "os" - "os/signal" - - "github.com/containerd/containerd/sys/reaper" - runc "github.com/containerd/go-runc" - "github.com/containerd/ttrpc" -) - -// setupSignals creates a new signal handler for all signals and sets the shim as a -// sub-reaper so that the container processes are reparented -func setupSignals() (chan os.Signal, error) { - signals := make(chan os.Signal, 2048) - signal.Notify(signals) - // make sure runc is setup to use the monitor - // for waiting on processes - runc.Monitor = reaper.Default - return signals, nil -} - -func newServer() (*ttrpc.Server, error) { - // for darwin, we omit the socket credentials because these syscalls are - // slightly different. since we don't have darwin support yet, this can be - // implemented later and the build can continue without issue. - return ttrpc.NewServer() -} diff --git a/cmd/containerd-shim/shim_freebsd.go b/cmd/containerd-shim/shim_freebsd.go deleted file mode 100644 index 5cafaef47..000000000 --- a/cmd/containerd-shim/shim_freebsd.go +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package main - -import ( - "os" - "os/signal" - - "github.com/containerd/containerd/sys/reaper" - - runc "github.com/containerd/go-runc" - "github.com/containerd/ttrpc" -) - -// setupSignals creates a new signal handler for all signals and sets the shim as a -// sub-reaper so that the container processes are reparented -func setupSignals() (chan os.Signal, error) { - signals := make(chan os.Signal, 2048) - signal.Notify(signals) - // make sure runc is setup to use the monitor - // for waiting on processes - runc.Monitor = reaper.Default - return signals, nil -} - -func newServer() (*ttrpc.Server, error) { - // for freebsd, we omit the socket credentials because these syscalls are - // slightly different. since we don't have freebsd support yet, this can be - // implemented later and the build can continue without issue. - return ttrpc.NewServer() -} diff --git a/cmd/containerd-shim/shim_linux.go b/cmd/containerd-shim/shim_linux.go deleted file mode 100644 index 66ebe36c6..000000000 --- a/cmd/containerd-shim/shim_linux.go +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright The containerd Authors. - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package main - -import ( - "os" - "os/signal" - - "github.com/containerd/containerd/sys/reaper" - runc "github.com/containerd/go-runc" - "github.com/containerd/ttrpc" - "golang.org/x/sys/unix" -) - -// setupSignals creates a new signal handler for all signals and sets the shim as a -// sub-reaper so that the container processes are reparented -func setupSignals() (chan os.Signal, error) { - signals := make(chan os.Signal, 32) - signal.Notify(signals, unix.SIGTERM, unix.SIGINT, unix.SIGCHLD, unix.SIGPIPE) - // make sure runc is setup to use the monitor - // for waiting on processes - runc.Monitor = reaper.Default - // set the shim as the subreaper for all orphaned processes created by the container - if err := reaper.SetSubreaper(1); err != nil { - return nil, err - } - return signals, nil -} - -func newServer() (*ttrpc.Server, error) { - return ttrpc.NewServer(ttrpc.WithServerHandshaker(ttrpc.UnixSocketRequireSameUser())) -} diff --git a/cmd/containerd/builtins/builtins_linux.go b/cmd/containerd/builtins/builtins_linux.go index 2671606f4..8df06891b 100644 --- a/cmd/containerd/builtins/builtins_linux.go +++ b/cmd/containerd/builtins/builtins_linux.go @@ -19,7 +19,6 @@ package builtins import ( _ "github.com/containerd/containerd/metrics/cgroups" _ "github.com/containerd/containerd/metrics/cgroups/v2" - _ "github.com/containerd/containerd/runtime/v1/linux" _ "github.com/containerd/containerd/runtime/v2/runc/options" _ "github.com/containerd/containerd/snapshots/native/plugin" _ "github.com/containerd/containerd/snapshots/overlay/plugin" diff --git a/cmd/ctr/commands/tasks/checkpoint.go b/cmd/ctr/commands/tasks/checkpoint.go index 78147da7d..172d1bdf1 100644 --- a/cmd/ctr/commands/tasks/checkpoint.go +++ b/cmd/ctr/commands/tasks/checkpoint.go @@ -22,8 +22,6 @@ import ( "github.com/containerd/containerd" "github.com/containerd/containerd/cmd/ctr/commands" - "github.com/containerd/containerd/plugin" - "github.com/containerd/containerd/runtime/linux/runctypes" "github.com/containerd/containerd/runtime/v2/runc/options" "github.com/urfave/cli" ) @@ -86,38 +84,21 @@ func withCheckpointOpts(rt string, context *cli.Context) containerd.CheckpointTa imagePath := context.String("image-path") workPath := context.String("work-path") - switch rt { - case plugin.RuntimeRuncV1, plugin.RuntimeRuncV2: - if r.Options == nil { - r.Options = &options.CheckpointOptions{} - } - opts, _ := r.Options.(*options.CheckpointOptions) - - if context.Bool("exit") { - opts.Exit = true - } - if imagePath != "" { - opts.ImagePath = imagePath - } - if workPath != "" { - opts.WorkPath = workPath - } - case plugin.RuntimeLinuxV1: - if r.Options == nil { - r.Options = &runctypes.CheckpointOptions{} - } - opts, _ := r.Options.(*runctypes.CheckpointOptions) - - if context.Bool("exit") { - opts.Exit = true - } - if imagePath != "" { - opts.ImagePath = imagePath - } - if workPath != "" { - opts.WorkPath = workPath - } + if r.Options == nil { + r.Options = &options.CheckpointOptions{} } + opts, _ := r.Options.(*options.CheckpointOptions) + + if context.Bool("exit") { + opts.Exit = true + } + if imagePath != "" { + opts.ImagePath = imagePath + } + if workPath != "" { + opts.WorkPath = workPath + } + return nil } } diff --git a/contrib/gce/configure.sh b/contrib/gce/configure.sh index 9be81afe4..5e3f5da82 100755 --- a/contrib/gce/configure.sh +++ b/contrib/gce/configure.sh @@ -240,7 +240,7 @@ containerd_extra_runtime_handler=${CONTAINERD_EXTRA_RUNTIME_HANDLER:-""} if [[ -n "${containerd_extra_runtime_handler}" ]]; then cat >> ${config_path} <