From 9ad087947d5ca65cf75c48666dc25677ad05e12c Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Sun, 11 Apr 2021 19:49:37 -0400 Subject: [PATCH 1/2] Switch all our tests to version 2 Also warn when someone uses version 1 Signed-off-by: Davanum Srinivas --- .github/workflows/ci.yml | 5 +++-- RELEASES.md | 4 +++- cmd/containerd/command/config.go | 2 +- integration/client/client_test.go | 4 ++-- integration/client/daemon_config_linux_test.go | 6 +++--- script/test/utils.sh | 7 ++++--- services/server/config/config.go | 12 +++++++++--- services/server/config/config_test.go | 6 +++--- 8 files changed, 28 insertions(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 864fe7cc3..8baa3f855 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -427,8 +427,9 @@ jobs: BDIR="$(mktemp -d -p $PWD)" mkdir -p ${BDIR}/{root,state} cat > ${BDIR}/config.toml < ${BDIR}/containerd-cri.log & diff --git a/RELEASES.md b/RELEASES.md index e58a00ba8..133e4d1bd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -294,7 +294,8 @@ The daemon's configuration file, commonly located in `/etc/containerd/config.tom is versioned and backwards compatible. The `version` field in the config file specifies the config's version. If no version number is specified inside the config file then it is assumed to be a version 1 config and parsed as such. -Use `version = 2` to enable version 2 config. +Please use `version = 2` to enable version 2 config as version 1 has been +deprecated. ### Not Covered @@ -324,3 +325,4 @@ The deprecated features are shown in the following table: |----------------------------------------------------------------------|---------------------|----------------------------| | Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 | | Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 | +| config.toml `version = 1` | containerd v1.5 | containerd v2.0 | diff --git a/cmd/containerd/command/config.go b/cmd/containerd/command/config.go index 7282f476c..8ba6deef0 100644 --- a/cmd/containerd/command/config.go +++ b/cmd/containerd/command/config.go @@ -120,7 +120,7 @@ var configCommand = cli.Command{ func platformAgnosticDefaultConfig() *srvconfig.Config { return &srvconfig.Config{ - Version: 1, + Version: 2, Root: defaults.DefaultRootDir, State: defaults.DefaultStateDir, GRPC: srvconfig.GRPCConfig{ diff --git a/integration/client/client_test.go b/integration/client/client_test.go index 109ec3c7a..022669ae1 100644 --- a/integration/client/client_test.go +++ b/integration/client/client_test.go @@ -503,12 +503,12 @@ func createShimDebugConfig() string { os.Exit(1) } defer f.Close() - if _, err := f.WriteString("version = 1\n"); err != nil { + if _, err := f.WriteString("version = 2\n"); err != nil { fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err) os.Exit(1) } - if _, err := f.WriteString("[plugins.linux]\n\tshim_debug = true\n"); err != nil { + if _, err := f.WriteString("[plugins.\"io.containerd.runtime.v1.linux\"]\n\tshim_debug = true\n"); err != nil { fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err) os.Exit(1) } diff --git a/integration/client/daemon_config_linux_test.go b/integration/client/daemon_config_linux_test.go index 18d425e50..d62e93877 100644 --- a/integration/client/daemon_config_linux_test.go +++ b/integration/client/daemon_config_linux_test.go @@ -129,9 +129,9 @@ func TestDaemonRuntimeRoot(t *testing.T) { } }() configTOML := ` -version = 1 +version = 2 [plugins] - [plugins.cri] + [plugins."io.containerd.grpc.v1.cri"] stream_server_port = "0" ` @@ -227,7 +227,7 @@ func TestDaemonCustomCgroup(t *testing.T) { customCgroup := fmt.Sprintf("%d", time.Now().Nanosecond()) configTOML := ` -version = 1 +version = 2 [cgroup] path = "` + customCgroup + `"` diff --git a/script/test/utils.sh b/script/test/utils.sh index e2819d1f1..6093bf8be 100755 --- a/script/test/utils.sh +++ b/script/test/utils.sh @@ -30,14 +30,15 @@ if [ -z "${CONTAINERD_CONFIG_FILE}" ]; then truncate --size 0 "${config_file}" if command -v sestatus >/dev/null 2>&1; then cat >>${config_file} <>${config_file} < Date: Mon, 12 Apr 2021 13:22:04 -0400 Subject: [PATCH 2/2] hcsshim seems to have been updated Signed-off-by: Davanum Srinivas --- vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go b/vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go index d4d800384..e3f1be333 100644 --- a/vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go +++ b/vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go @@ -25,7 +25,9 @@ func ExportLayerToTar(ctx context.Context, w io.Writer, path string, parentLayer if err != nil { return err } - defer hcsshim.DeactivateLayer(driverInfo, path) + defer func() { + _ = hcsshim.DeactivateLayer(driverInfo, path) + }() // Prepare and unprepare the layer to ensure that it has been initialized. err = hcsshim.PrepareLayer(driverInfo, path, parentLayerPaths)