Skip to content

Commit e96d2a5

Browse files
committed
Revert "remove two very old no longer used runtime options"
Signed-off-by: Mike Brown <[email protected]>
1 parent 7e3fd8d commit e96d2a5

3 files changed

Lines changed: 105 additions & 0 deletions

File tree

docs/cri/config.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ version = 2
124124
# default_runtime_name is the default runtime name to use.
125125
default_runtime_name = "runc"
126126

127+
# 'plugins."io.containerd.grpc.v1.cri".containerd.default_runtime' is the runtime to use in containerd.
128+
# DEPRECATED: use `default_runtime_name` and `plugins."io.containerd.grpc.v1.cri".runtimes` instead.
129+
# Remove in containerd 1.4.
130+
[plugins."io.containerd.grpc.v1.cri".containerd.default_runtime]
131+
132+
# 'plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime' is a runtime to run untrusted workloads on it.
133+
# DEPRECATED: use `untrusted` runtime in `plugins."io.containerd.grpc.v1.cri".runtimes` instead.
134+
# Remove in containerd 1.4.
135+
[plugins."io.containerd.grpc.v1.cri".containerd.untrusted_workload_runtime]
136+
127137
# 'plugins."io.containerd.grpc.v1.cri".containerd.runtimes' is a map from CRI RuntimeHandler strings, which specify types
128138
# of runtime configurations, to the matching configurations.
129139
# In this example, 'runc' is the RuntimeHandler string to match.

pkg/cri/config/config.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,13 @@ type ContainerdConfig struct {
6464
Snapshotter string `toml:"snapshotter" json:"snapshotter"`
6565
// DefaultRuntimeName is the default runtime name to use from the runtimes table.
6666
DefaultRuntimeName string `toml:"default_runtime_name" json:"defaultRuntimeName"`
67+
// DefaultRuntime is the default runtime to use in containerd.
68+
// This runtime is used when no runtime handler (or the empty string) is provided.
69+
// DEPRECATED: use DefaultRuntimeName instead. Remove in containerd 1.4.
70+
DefaultRuntime Runtime `toml:"default_runtime" json:"defaultRuntime"`
71+
// UntrustedWorkloadRuntime is a runtime to run untrusted workloads on it.
72+
// DEPRECATED: use `untrusted` runtime in Runtimes instead. Remove in containerd 1.4.
73+
UntrustedWorkloadRuntime Runtime `toml:"untrusted_workload_runtime" json:"untrustedWorkloadRuntime"`
6774
// Runtimes is a map from CRI RuntimeHandler strings, which specify types of runtime
6875
// configurations, to the matching configurations.
6976
Runtimes map[string]Runtime `toml:"runtimes" json:"runtimes"`
@@ -300,6 +307,22 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
300307
c.ContainerdConfig.Runtimes = make(map[string]Runtime)
301308
}
302309

310+
// Validation for deprecated untrusted_workload_runtime.
311+
if c.ContainerdConfig.UntrustedWorkloadRuntime.Type != "" {
312+
log.G(ctx).Warning("`untrusted_workload_runtime` is deprecated, please use `untrusted` runtime in `runtimes` instead")
313+
if _, ok := c.ContainerdConfig.Runtimes[RuntimeUntrusted]; ok {
314+
return errors.Errorf("conflicting definitions: configuration includes both `untrusted_workload_runtime` and `runtimes[%q]`", RuntimeUntrusted)
315+
}
316+
c.ContainerdConfig.Runtimes[RuntimeUntrusted] = c.ContainerdConfig.UntrustedWorkloadRuntime
317+
}
318+
319+
// Validation for deprecated default_runtime field.
320+
if c.ContainerdConfig.DefaultRuntime.Type != "" {
321+
log.G(ctx).Warning("`default_runtime` is deprecated, please use `default_runtime_name` to reference the default configuration you have defined in `runtimes`")
322+
c.ContainerdConfig.DefaultRuntimeName = RuntimeDefault
323+
c.ContainerdConfig.Runtimes[RuntimeDefault] = c.ContainerdConfig.DefaultRuntime
324+
}
325+
303326
// Validation for default_runtime_name
304327
if c.ContainerdConfig.DefaultRuntimeName == "" {
305328
return errors.New("`default_runtime_name` is empty")

pkg/cri/config/config_test.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,78 @@ func TestValidateConfig(t *testing.T) {
3131
expectedErr string
3232
expected *PluginConfig
3333
}{
34+
"deprecated untrusted_workload_runtime": {
35+
config: &PluginConfig{
36+
ContainerdConfig: ContainerdConfig{
37+
DefaultRuntimeName: RuntimeDefault,
38+
UntrustedWorkloadRuntime: Runtime{
39+
Type: "untrusted",
40+
},
41+
Runtimes: map[string]Runtime{
42+
RuntimeDefault: {
43+
Type: "default",
44+
},
45+
},
46+
},
47+
},
48+
expected: &PluginConfig{
49+
ContainerdConfig: ContainerdConfig{
50+
DefaultRuntimeName: RuntimeDefault,
51+
UntrustedWorkloadRuntime: Runtime{
52+
Type: "untrusted",
53+
},
54+
Runtimes: map[string]Runtime{
55+
RuntimeUntrusted: {
56+
Type: "untrusted",
57+
},
58+
RuntimeDefault: {
59+
Type: "default",
60+
},
61+
},
62+
},
63+
},
64+
},
65+
"both untrusted_workload_runtime and runtime[untrusted]": {
66+
config: &PluginConfig{
67+
ContainerdConfig: ContainerdConfig{
68+
DefaultRuntimeName: RuntimeDefault,
69+
UntrustedWorkloadRuntime: Runtime{
70+
Type: "untrusted-1",
71+
},
72+
Runtimes: map[string]Runtime{
73+
RuntimeUntrusted: {
74+
Type: "untrusted-2",
75+
},
76+
RuntimeDefault: {
77+
Type: "default",
78+
},
79+
},
80+
},
81+
},
82+
expectedErr: fmt.Sprintf("conflicting definitions: configuration includes both `untrusted_workload_runtime` and `runtimes[%q]`", RuntimeUntrusted),
83+
},
84+
"deprecated default_runtime": {
85+
config: &PluginConfig{
86+
ContainerdConfig: ContainerdConfig{
87+
DefaultRuntime: Runtime{
88+
Type: "default",
89+
},
90+
},
91+
},
92+
expected: &PluginConfig{
93+
ContainerdConfig: ContainerdConfig{
94+
DefaultRuntime: Runtime{
95+
Type: "default",
96+
},
97+
DefaultRuntimeName: RuntimeDefault,
98+
Runtimes: map[string]Runtime{
99+
RuntimeDefault: {
100+
Type: "default",
101+
},
102+
},
103+
},
104+
},
105+
},
34106
"no default_runtime_name": {
35107
config: &PluginConfig{},
36108
expectedErr: "`default_runtime_name` is empty",

0 commit comments

Comments
 (0)