Merge pull request #1116 from Random-Liu/per-pod-shim
Enable runc.v2 as the default runtime in test.
This commit is contained in:
commit
6d353571e6
@ -164,10 +164,6 @@ disabled_plugins = ["restart"]
|
|||||||
[debug]
|
[debug]
|
||||||
level = "${log_level}"
|
level = "${log_level}"
|
||||||
|
|
||||||
[plugins.linux]
|
|
||||||
shim = "${CONTAINERD_HOME}/usr/local/bin/containerd-shim"
|
|
||||||
runtime = "${CONTAINERD_HOME}/usr/local/sbin/runc"
|
|
||||||
|
|
||||||
[plugins.cri]
|
[plugins.cri]
|
||||||
stream_server_address = "127.0.0.1"
|
stream_server_address = "127.0.0.1"
|
||||||
stream_server_port = "0"
|
stream_server_port = "0"
|
||||||
@ -178,6 +174,10 @@ disabled_plugins = ["restart"]
|
|||||||
conf_template = "${cni_template_path}"
|
conf_template = "${cni_template_path}"
|
||||||
[plugins.cri.registry.mirrors."docker.io"]
|
[plugins.cri.registry.mirrors."docker.io"]
|
||||||
endpoint = ["https://mirror.gcr.io","https://registry-1.docker.io"]
|
endpoint = ["https://mirror.gcr.io","https://registry-1.docker.io"]
|
||||||
|
[plugins.cri.containerd.default_runtime]
|
||||||
|
runtime_type = "io.containerd.runc.v2"
|
||||||
|
[plugins.cri.containerd.default_runtime.options]
|
||||||
|
BinaryName = "${CONTAINERD_HOME}/usr/local/sbin/runc"
|
||||||
EOF
|
EOF
|
||||||
chmod 644 "${config_path}"
|
chmod 644 "${config_path}"
|
||||||
|
|
||||||
|
@ -122,8 +122,10 @@ const (
|
|||||||
const (
|
const (
|
||||||
// linuxRuntime is the legacy linux runtime for shim v1.
|
// linuxRuntime is the legacy linux runtime for shim v1.
|
||||||
linuxRuntime = "io.containerd.runtime.v1.linux"
|
linuxRuntime = "io.containerd.runtime.v1.linux"
|
||||||
// runcRuntime is the runc runtime for shim v2.
|
// runcRuntimeV1 is the runc v1 runtime for shim v2.
|
||||||
runcRuntime = "io.containerd.runc.v1"
|
runcRuntimeV1 = "io.containerd.runc.v1"
|
||||||
|
// runcRuntimeV2 is the runc v2 runtime for shim v2.
|
||||||
|
runcRuntimeV2 = "io.containerd.runc.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// makeSandboxName generates sandbox name from sandbox metadata. The name
|
// makeSandboxName generates sandbox name from sandbox metadata. The name
|
||||||
@ -427,7 +429,9 @@ func generateRuntimeOptions(r criconfig.Runtime, c criconfig.Config) (interface{
|
|||||||
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
|
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
|
||||||
func getRuntimeOptionsType(t string) interface{} {
|
func getRuntimeOptionsType(t string) interface{} {
|
||||||
switch t {
|
switch t {
|
||||||
case runcRuntime:
|
case runcRuntimeV1:
|
||||||
|
fallthrough
|
||||||
|
case runcRuntimeV2:
|
||||||
return &runcoptions.Options{}
|
return &runcoptions.Options{}
|
||||||
case linuxRuntime:
|
case linuxRuntime:
|
||||||
return &runctypes.RuncOptions{}
|
return &runctypes.RuncOptions{}
|
||||||
|
@ -215,7 +215,9 @@ systemd_cgroup = true
|
|||||||
[containerd.default_runtime]
|
[containerd.default_runtime]
|
||||||
runtime_type = "` + linuxRuntime + `"
|
runtime_type = "` + linuxRuntime + `"
|
||||||
[containerd.runtimes.runc]
|
[containerd.runtimes.runc]
|
||||||
runtime_type = "` + runcRuntime + `"
|
runtime_type = "` + runcRuntimeV1 + `"
|
||||||
|
[containerd.runtimes.runcv2]
|
||||||
|
runtime_type = "` + runcRuntimeV2 + `"
|
||||||
`
|
`
|
||||||
nonNilOpts := `
|
nonNilOpts := `
|
||||||
systemd_cgroup = true
|
systemd_cgroup = true
|
||||||
@ -227,30 +229,41 @@ systemd_cgroup = true
|
|||||||
Runtime = "default"
|
Runtime = "default"
|
||||||
RuntimeRoot = "/default"
|
RuntimeRoot = "/default"
|
||||||
[containerd.runtimes.runc]
|
[containerd.runtimes.runc]
|
||||||
runtime_type = "` + runcRuntime + `"
|
runtime_type = "` + runcRuntimeV1 + `"
|
||||||
[containerd.runtimes.runc.options]
|
[containerd.runtimes.runc.options]
|
||||||
BinaryName = "runc"
|
BinaryName = "runc"
|
||||||
Root = "/runc"
|
Root = "/runc"
|
||||||
NoNewKeyring = true
|
NoNewKeyring = true
|
||||||
|
[containerd.runtimes.runcv2]
|
||||||
|
runtime_type = "` + runcRuntimeV2 + `"
|
||||||
|
[containerd.runtimes.runcv2.options]
|
||||||
|
BinaryName = "runc"
|
||||||
|
Root = "/runcv2"
|
||||||
|
NoNewKeyring = true
|
||||||
`
|
`
|
||||||
var nilOptsConfig, nonNilOptsConfig criconfig.Config
|
var nilOptsConfig, nonNilOptsConfig criconfig.Config
|
||||||
_, err := toml.Decode(nilOpts, &nilOptsConfig)
|
_, err := toml.Decode(nilOpts, &nilOptsConfig)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
_, err = toml.Decode(nonNilOpts, &nonNilOptsConfig)
|
_, err = toml.Decode(nonNilOpts, &nonNilOptsConfig)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Len(t, nilOptsConfig.Runtimes, 1)
|
require.Len(t, nilOptsConfig.Runtimes, 2)
|
||||||
require.Len(t, nonNilOptsConfig.Runtimes, 1)
|
require.Len(t, nonNilOptsConfig.Runtimes, 2)
|
||||||
|
|
||||||
for desc, test := range map[string]struct {
|
for desc, test := range map[string]struct {
|
||||||
r criconfig.Runtime
|
r criconfig.Runtime
|
||||||
c criconfig.Config
|
c criconfig.Config
|
||||||
expectedOptions interface{}
|
expectedOptions interface{}
|
||||||
}{
|
}{
|
||||||
"when options is nil, should return nil option for non legacy runtime": {
|
"when options is nil, should return nil option for io.containerd.runc.v1": {
|
||||||
r: nilOptsConfig.Runtimes["runc"],
|
r: nilOptsConfig.Runtimes["runc"],
|
||||||
c: nilOptsConfig,
|
c: nilOptsConfig,
|
||||||
expectedOptions: nil,
|
expectedOptions: nil,
|
||||||
},
|
},
|
||||||
|
"when options is nil, should return nil option for io.containerd.runc.v2": {
|
||||||
|
r: nilOptsConfig.Runtimes["runcv2"],
|
||||||
|
c: nilOptsConfig,
|
||||||
|
expectedOptions: nil,
|
||||||
|
},
|
||||||
"when options is nil, should use legacy fields for legacy runtime": {
|
"when options is nil, should use legacy fields for legacy runtime": {
|
||||||
r: nilOptsConfig.DefaultRuntime,
|
r: nilOptsConfig.DefaultRuntime,
|
||||||
c: nilOptsConfig,
|
c: nilOptsConfig,
|
||||||
@ -267,6 +280,15 @@ systemd_cgroup = true
|
|||||||
NoNewKeyring: true,
|
NoNewKeyring: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
"when options is not nil, should be able to decode for io.containerd.runc.v2": {
|
||||||
|
r: nonNilOptsConfig.Runtimes["runcv2"],
|
||||||
|
c: nonNilOptsConfig,
|
||||||
|
expectedOptions: &runcoptions.Options{
|
||||||
|
BinaryName: "runc",
|
||||||
|
Root: "/runcv2",
|
||||||
|
NoNewKeyring: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
"when options is not nil, should be able to decode for legacy runtime": {
|
"when options is not nil, should be able to decode for legacy runtime": {
|
||||||
r: nonNilOptsConfig.DefaultRuntime,
|
r: nonNilOptsConfig.DefaultRuntime,
|
||||||
c: nonNilOptsConfig,
|
c: nonNilOptsConfig,
|
||||||
|
Loading…
Reference in New Issue
Block a user