Skip to content

Commit 545e79a

Browse files
authored
Merge pull request containerd#3337 from crosbymichael/config-bk
Fix backwards compat with v2 containerd configs
2 parents 53896d7 + 31afff2 commit 545e79a

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ script:
7474
- go build -i .
7575
- make check
7676
- if [ "$GOOS" = "linux" ]; then make check-protos check-api-descriptors; fi
77-
- |
78-
sudo mkdir -p /etc/containerd
79-
sudo bash -c "cat > /etc/containerd/config.toml <<EOF
80-
version = 1
81-
EOF"
8277
- make build
8378
- make binaries
8479
- if [ "$TRAVIS_GOOS" = "linux" ]; then sudo make install ; fi
@@ -91,7 +86,6 @@ script:
9186
if [ "$TRAVIS_GOOS" = "linux" ]; then
9287
sudo mkdir -p /etc/containerd
9388
sudo bash -c "cat > /etc/containerd/config.toml <<EOF
94-
version = 1
9589
[plugins.cri.containerd.default_runtime]
9690
runtime_type = \"${TEST_RUNTIME}\"
9791
EOF"

cmd/containerd/command/config.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ var configCommand = cli.Command{
5050
config := &Config{
5151
Config: defaultConfig(),
5252
}
53+
// for the time being, keep the defaultConfig's version set at 1 so that
54+
// when a config without a version is loaded from disk and has no version
55+
// set, we assume it's a v1 config. But when generating new configs via
56+
// this command, generate the v2 config
57+
config.Config.Version = 2
5358
plugins, err := server.LoadPlugins(gocontext.Background(), config.Config)
5459
if err != nil {
5560
return err

cmd/containerd/command/config_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
func defaultConfig() *srvconfig.Config {
2525
return &srvconfig.Config{
26-
Version: 2,
26+
Version: 1,
2727
Root: defaults.DefaultRootDir,
2828
State: defaults.DefaultStateDir,
2929
GRPC: srvconfig.GRPCConfig{

cmd/containerd/command/config_unsupported.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525

2626
func defaultConfig() *srvconfig.Config {
2727
return &srvconfig.Config{
28-
Version: 2,
28+
Version: 1,
2929
Root: defaults.DefaultRootDir,
3030
State: defaults.DefaultStateDir,
3131
GRPC: srvconfig.GRPCConfig{

cmd/containerd/command/config_windows.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import (
2323

2424
func defaultConfig() *srvconfig.Config {
2525
return &srvconfig.Config{
26-
Version: 2,
26+
Version: 1,
2727
Root: defaults.DefaultRootDir,
2828
State: defaults.DefaultStateDir,
2929
GRPC: srvconfig.GRPCConfig{

0 commit comments

Comments
 (0)