Skip to content

Commit 054a3e2

Browse files
authored
Merge pull request #5335 from dims/drop-support-for-version-1
2 parents 2a2d779 + 75097b8 commit 054a3e2

9 files changed

Lines changed: 31 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,8 +427,9 @@ jobs:
427427
BDIR="$(mktemp -d -p $PWD)"
428428
mkdir -p ${BDIR}/{root,state}
429429
cat > ${BDIR}/config.toml <<EOF
430-
[plugins.cri.containerd.default_runtime]
431-
runtime_type = "${TEST_RUNTIME}"
430+
version = 2
431+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
432+
runtime_type = "${TEST_RUNTIME}"
432433
EOF
433434
sudo ls /etc/cni/net.d
434435
sudo PATH=$PATH BDIR=$BDIR /usr/local/bin/containerd -a ${BDIR}/c.sock --config ${BDIR}/config.toml --root ${BDIR}/root --state ${BDIR}/state --log-level debug &> ${BDIR}/containerd-cri.log &

RELEASES.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,8 @@ The daemon's configuration file, commonly located in `/etc/containerd/config.tom
294294
is versioned and backwards compatible. The `version` field in the config
295295
file specifies the config's version. If no version number is specified inside
296296
the config file then it is assumed to be a version 1 config and parsed as such.
297-
Use `version = 2` to enable version 2 config.
297+
Please use `version = 2` to enable version 2 config as version 1 has been
298+
deprecated.
298299

299300
### Not Covered
300301

@@ -324,3 +325,4 @@ The deprecated features are shown in the following table:
324325
|----------------------------------------------------------------------|---------------------|----------------------------|
325326
| Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 |
326327
| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 |
328+
| config.toml `version = 1` | containerd v1.5 | containerd v2.0 |

cmd/containerd/command/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ var configCommand = cli.Command{
120120

121121
func platformAgnosticDefaultConfig() *srvconfig.Config {
122122
return &srvconfig.Config{
123-
Version: 1,
123+
Version: 2,
124124
Root: defaults.DefaultRootDir,
125125
State: defaults.DefaultStateDir,
126126
GRPC: srvconfig.GRPCConfig{

integration/client/client_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,12 +503,12 @@ func createShimDebugConfig() string {
503503
os.Exit(1)
504504
}
505505
defer f.Close()
506-
if _, err := f.WriteString("version = 1\n"); err != nil {
506+
if _, err := f.WriteString("version = 2\n"); err != nil {
507507
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
508508
os.Exit(1)
509509
}
510510

511-
if _, err := f.WriteString("[plugins.linux]\n\tshim_debug = true\n"); err != nil {
511+
if _, err := f.WriteString("[plugins.\"io.containerd.runtime.v1.linux\"]\n\tshim_debug = true\n"); err != nil {
512512
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
513513
os.Exit(1)
514514
}

integration/client/daemon_config_linux_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ func TestDaemonRuntimeRoot(t *testing.T) {
129129
}
130130
}()
131131
configTOML := `
132-
version = 1
132+
version = 2
133133
[plugins]
134-
[plugins.cri]
134+
[plugins."io.containerd.grpc.v1.cri"]
135135
stream_server_port = "0"
136136
`
137137

@@ -227,7 +227,7 @@ func TestDaemonCustomCgroup(t *testing.T) {
227227

228228
customCgroup := fmt.Sprintf("%d", time.Now().Nanosecond())
229229
configTOML := `
230-
version = 1
230+
version = 2
231231
[cgroup]
232232
path = "` + customCgroup + `"`
233233

script/test/utils.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ if [ -z "${CONTAINERD_CONFIG_FILE}" ]; then
3030
truncate --size 0 "${config_file}"
3131
if command -v sestatus >/dev/null 2>&1; then
3232
cat >>${config_file} <<EOF
33-
[plugins.cri]
33+
version=2
34+
[plugins."io.containerd.grpc.v1.cri"]
3435
enable_selinux = true
3536
EOF
3637
fi
3738
if [ -n "${CONTAINERD_RUNTIME}" ]; then
3839
cat >>${config_file} <<EOF
39-
[plugins.cri.containerd.default_runtime]
40-
runtime_type="${CONTAINERD_RUNTIME}"
40+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
41+
runtime_type = "${CONTAINERD_RUNTIME}"
4142
EOF
4243
fi
4344
CONTAINERD_CONFIG_FILE="${config_file}"

services/server/config/config.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/imdario/mergo"
2424
"github.com/pelletier/go-toml"
2525
"github.com/pkg/errors"
26+
"github.com/sirupsen/logrus"
2627

2728
"github.com/containerd/containerd/errdefs"
2829
"github.com/containerd/containerd/plugin"
@@ -94,8 +95,9 @@ func (c *Config) GetVersion() int {
9495

9596
// ValidateV2 validates the config for a v2 file
9697
func (c *Config) ValidateV2() error {
97-
if c.GetVersion() != 2 {
98-
return nil
98+
version := c.GetVersion()
99+
if version < 2 {
100+
logrus.Warnf("deprecated version : `%d`, please switch to version `2`", version)
99101
}
100102
for _, p := range c.DisabledPlugins {
101103
if len(strings.Split(p, ".")) < 4 {
@@ -258,7 +260,11 @@ func LoadConfig(path string, out *Config) error {
258260
out.Imports = append(out.Imports, path)
259261
}
260262

261-
return out.ValidateV2()
263+
err := out.ValidateV2()
264+
if err != nil {
265+
return errors.Wrapf(err, "failed to load TOML from %s", path)
266+
}
267+
return nil
262268
}
263269

264270
// loadConfigFile decodes a TOML file at the given path

services/server/config/config_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ imports = ["data1.toml", "data2.toml"]
185185

186186
func TestDecodePlugin(t *testing.T) {
187187
data := `
188-
version = 1
189-
[plugins.linux]
188+
version = 2
189+
[plugins."io.containerd.runtime.v1.linux"]
190190
shim_debug = true
191191
`
192192

@@ -203,7 +203,7 @@ version = 1
203203
assert.NilError(t, err)
204204

205205
pluginConfig := map[string]interface{}{}
206-
_, err = out.Decode(&plugin.Registration{ID: "linux", Config: &pluginConfig})
206+
_, err = out.Decode(&plugin.Registration{Type: "io.containerd.runtime.v1", ID: "linux", Config: &pluginConfig})
207207
assert.NilError(t, err)
208208
assert.Equal(t, true, pluginConfig["shim_debug"])
209209
}

vendor/github.com/Microsoft/hcsshim/pkg/ociwclayer/export.go

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)