Skip to content

Commit 6d35357

Browse files
authored
Merge pull request containerd#1116 from Random-Liu/per-pod-shim
Enable runc.v2 as the default runtime in test.
2 parents 0e2afb6 + fae4f79 commit 6d35357

3 files changed

Lines changed: 38 additions & 12 deletions

File tree

cluster/gce/configure.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ disabled_plugins = ["restart"]
164164
[debug]
165165
level = "${log_level}"
166166
167-
[plugins.linux]
168-
shim = "${CONTAINERD_HOME}/usr/local/bin/containerd-shim"
169-
runtime = "${CONTAINERD_HOME}/usr/local/sbin/runc"
170-
171167
[plugins.cri]
172168
stream_server_address = "127.0.0.1"
173169
stream_server_port = "0"
@@ -178,6 +174,10 @@ disabled_plugins = ["restart"]
178174
conf_template = "${cni_template_path}"
179175
[plugins.cri.registry.mirrors."docker.io"]
180176
endpoint = ["https://mirror.gcr.io","https://registry-1.docker.io"]
177+
[plugins.cri.containerd.default_runtime]
178+
runtime_type = "io.containerd.runc.v2"
179+
[plugins.cri.containerd.default_runtime.options]
180+
BinaryName = "${CONTAINERD_HOME}/usr/local/sbin/runc"
181181
EOF
182182
chmod 644 "${config_path}"
183183

pkg/server/helpers.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,10 @@ const (
122122
const (
123123
// linuxRuntime is the legacy linux runtime for shim v1.
124124
linuxRuntime = "io.containerd.runtime.v1.linux"
125-
// runcRuntime is the runc runtime for shim v2.
126-
runcRuntime = "io.containerd.runc.v1"
125+
// runcRuntimeV1 is the runc v1 runtime for shim v2.
126+
runcRuntimeV1 = "io.containerd.runc.v1"
127+
// runcRuntimeV2 is the runc v2 runtime for shim v2.
128+
runcRuntimeV2 = "io.containerd.runc.v2"
127129
)
128130

129131
// makeSandboxName generates sandbox name from sandbox metadata. The name
@@ -427,7 +429,9 @@ func generateRuntimeOptions(r criconfig.Runtime, c criconfig.Config) (interface{
427429
// getRuntimeOptionsType gets empty runtime options by the runtime type name.
428430
func getRuntimeOptionsType(t string) interface{} {
429431
switch t {
430-
case runcRuntime:
432+
case runcRuntimeV1:
433+
fallthrough
434+
case runcRuntimeV2:
431435
return &runcoptions.Options{}
432436
case linuxRuntime:
433437
return &runctypes.RuncOptions{}

pkg/server/helpers_test.go

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,9 @@ systemd_cgroup = true
215215
[containerd.default_runtime]
216216
runtime_type = "` + linuxRuntime + `"
217217
[containerd.runtimes.runc]
218-
runtime_type = "` + runcRuntime + `"
218+
runtime_type = "` + runcRuntimeV1 + `"
219+
[containerd.runtimes.runcv2]
220+
runtime_type = "` + runcRuntimeV2 + `"
219221
`
220222
nonNilOpts := `
221223
systemd_cgroup = true
@@ -227,30 +229,41 @@ systemd_cgroup = true
227229
Runtime = "default"
228230
RuntimeRoot = "/default"
229231
[containerd.runtimes.runc]
230-
runtime_type = "` + runcRuntime + `"
232+
runtime_type = "` + runcRuntimeV1 + `"
231233
[containerd.runtimes.runc.options]
232234
BinaryName = "runc"
233235
Root = "/runc"
234236
NoNewKeyring = true
237+
[containerd.runtimes.runcv2]
238+
runtime_type = "` + runcRuntimeV2 + `"
239+
[containerd.runtimes.runcv2.options]
240+
BinaryName = "runc"
241+
Root = "/runcv2"
242+
NoNewKeyring = true
235243
`
236244
var nilOptsConfig, nonNilOptsConfig criconfig.Config
237245
_, err := toml.Decode(nilOpts, &nilOptsConfig)
238246
require.NoError(t, err)
239247
_, err = toml.Decode(nonNilOpts, &nonNilOptsConfig)
240248
require.NoError(t, err)
241-
require.Len(t, nilOptsConfig.Runtimes, 1)
242-
require.Len(t, nonNilOptsConfig.Runtimes, 1)
249+
require.Len(t, nilOptsConfig.Runtimes, 2)
250+
require.Len(t, nonNilOptsConfig.Runtimes, 2)
243251

244252
for desc, test := range map[string]struct {
245253
r criconfig.Runtime
246254
c criconfig.Config
247255
expectedOptions interface{}
248256
}{
249-
"when options is nil, should return nil option for non legacy runtime": {
257+
"when options is nil, should return nil option for io.containerd.runc.v1": {
250258
r: nilOptsConfig.Runtimes["runc"],
251259
c: nilOptsConfig,
252260
expectedOptions: nil,
253261
},
262+
"when options is nil, should return nil option for io.containerd.runc.v2": {
263+
r: nilOptsConfig.Runtimes["runcv2"],
264+
c: nilOptsConfig,
265+
expectedOptions: nil,
266+
},
254267
"when options is nil, should use legacy fields for legacy runtime": {
255268
r: nilOptsConfig.DefaultRuntime,
256269
c: nilOptsConfig,
@@ -267,6 +280,15 @@ systemd_cgroup = true
267280
NoNewKeyring: true,
268281
},
269282
},
283+
"when options is not nil, should be able to decode for io.containerd.runc.v2": {
284+
r: nonNilOptsConfig.Runtimes["runcv2"],
285+
c: nonNilOptsConfig,
286+
expectedOptions: &runcoptions.Options{
287+
BinaryName: "runc",
288+
Root: "/runcv2",
289+
NoNewKeyring: true,
290+
},
291+
},
270292
"when options is not nil, should be able to decode for legacy runtime": {
271293
r: nonNilOptsConfig.DefaultRuntime,
272294
c: nonNilOptsConfig,

0 commit comments

Comments
 (0)