Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/1.7] cri: add deprecation warnings for deprecated CRI configs #9469

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkg/cri/config/config.go
Expand Up @@ -433,11 +433,13 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
if _, ok := c.ContainerdConfig.Runtimes[RuntimeUntrusted]; ok {
return warnings, fmt.Errorf("conflicting definitions: configuration includes both `untrusted_workload_runtime` and `runtimes[%q]`", RuntimeUntrusted)
}
warnings = append(warnings, deprecation.CRIUntrustedWorkloadRuntime)
c.ContainerdConfig.Runtimes[RuntimeUntrusted] = c.ContainerdConfig.UntrustedWorkloadRuntime
}

// Validation for deprecated default_runtime field.
if c.ContainerdConfig.DefaultRuntime.Type != "" {
warnings = append(warnings, deprecation.CRIDefaultRuntime)
log.G(ctx).Warning("`default_runtime` is deprecated, please use `default_runtime_name` to reference the default configuration you have defined in `runtimes`")
c.ContainerdConfig.DefaultRuntimeName = RuntimeDefault
c.ContainerdConfig.Runtimes[RuntimeDefault] = c.ContainerdConfig.DefaultRuntime
Expand All @@ -456,6 +458,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
if c.ContainerdConfig.Runtimes[c.ContainerdConfig.DefaultRuntimeName].Type != plugin.RuntimeLinuxV1 {
return warnings, fmt.Errorf("`systemd_cgroup` only works for runtime %s", plugin.RuntimeLinuxV1)
}
warnings = append(warnings, deprecation.CRISystemdCgroupV1)
log.G(ctx).Warning("`systemd_cgroup` is deprecated, please use runtime `options` instead")
}
if c.NoPivot {
Expand All @@ -470,12 +473,14 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
if r.Type != plugin.RuntimeLinuxV1 {
return warnings, fmt.Errorf("`runtime_engine` only works for runtime %s", plugin.RuntimeLinuxV1)
}
warnings = append(warnings, deprecation.CRIRuntimeEngine)
log.G(ctx).Warning("`runtime_engine` is deprecated, please use runtime `options` instead")
}
if r.Root != "" {
if r.Type != plugin.RuntimeLinuxV1 {
return warnings, fmt.Errorf("`runtime_root` only works for runtime %s", plugin.RuntimeLinuxV1)
}
warnings = append(warnings, deprecation.CRIRuntimeRoot)
log.G(ctx).Warning("`runtime_root` is deprecated, please use runtime `options` instead")
}
if !r.PrivilegedWithoutHostDevices && r.PrivilegedWithoutHostDevicesAllDevicesAllowed {
Expand Down
5 changes: 5 additions & 0 deletions pkg/cri/config/config_test.go
Expand Up @@ -67,6 +67,7 @@ func TestValidateConfig(t *testing.T) {
},
},
},
warnings: []deprecation.Warning{deprecation.CRIUntrustedWorkloadRuntime},
},
"both untrusted_workload_runtime and runtime[untrusted]": {
config: &PluginConfig{
Expand Down Expand Up @@ -109,6 +110,7 @@ func TestValidateConfig(t *testing.T) {
},
},
},
warnings: []deprecation.Warning{deprecation.CRIDefaultRuntime},
},
"no default_runtime_name": {
config: &PluginConfig{},
Expand Down Expand Up @@ -146,6 +148,7 @@ func TestValidateConfig(t *testing.T) {
},
},
},
warnings: []deprecation.Warning{deprecation.CRISystemdCgroupV1},
},
"deprecated systemd_cgroup for v2 runtime": {
config: &PluginConfig{
Expand Down Expand Up @@ -224,6 +227,7 @@ func TestValidateConfig(t *testing.T) {
},
},
},
warnings: []deprecation.Warning{deprecation.CRIRuntimeEngine},
},
"deprecated runtime_engine for v2 runtime": {
config: &PluginConfig{
Expand Down Expand Up @@ -263,6 +267,7 @@ func TestValidateConfig(t *testing.T) {
},
},
},
warnings: []deprecation.Warning{deprecation.CRIRuntimeRoot},
},
"deprecated runtime_root for v2 runtime": {
config: &PluginConfig{
Expand Down
26 changes: 23 additions & 3 deletions pkg/deprecation/deprecation.go
Expand Up @@ -25,6 +25,16 @@ const (
PullSchema1Image Warning = Prefix + "pull-schema-1-image"
// GoPluginLibrary is a warning for the use of dynamic library Go plugins
GoPluginLibrary Warning = Prefix + "go-plugin-library"
// CRISystemdCgroupV1 is a warning for the `systemd_cgroup` property
CRISystemdCgroupV1 Warning = Prefix + "cri-systemd-cgroup-v1"
// CRIUntrustedWorkloadRuntime is a warning for the `untrusted_workload_runtime` property
CRIUntrustedWorkloadRuntime Warning = Prefix + "cri-untrusted-workload-runtime"
// CRIDefaultRuntime is a warning for the `default_runtime` property
CRIDefaultRuntime Warning = Prefix + "cri-default-runtime"
// CRIRuntimeEngine is a warning for the `runtime_engine` property
CRIRuntimeEngine Warning = Prefix + "cri-runtime-engine"
// CRIRuntimeRoot is a warning for the `runtime_root` property
CRIRuntimeRoot Warning = Prefix + "cri-runtime-root"
// CRIRegistryMirrors is a warning for the use of the `mirrors` property
CRIRegistryMirrors Warning = Prefix + "cri-registry-mirrors"
// CRIRegistryAuths is a warning for the use of the `auths` property
Expand All @@ -45,11 +55,21 @@ var messages = map[Warning]string{
PullSchema1Image: "Schema 1 images are deprecated since containerd v1.7 and removed in containerd v2.0. " +
`Since containerd v1.7.8, schema 1 images are identified by the "io.containerd.image/converted-docker-schema1" label.`,
GoPluginLibrary: "Dynamically-linked Go plugins as containerd runtimes will be deprecated in containerd v2.0 and removed in containerd v2.1.",
CRIRegistryMirrors: "The `mirrors` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0." +
CRISystemdCgroupV1: "The `systemd_cgroup` property (old form) of `[plugins.\"io.containerd.grpc.v1.cri\"] is deprecated since containerd v1.3 and will be removed in containerd v2.0. " +
"Use `SystemdCgroup` in [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.runc.options] options instead.",
CRIUntrustedWorkloadRuntime: "The `untrusted_workload_runtime` property of [plugins.\"io.containerd.grpc.v1.cri\".containerd] is deprecated since containerd v1.2 and will be removed in containerd v2.0. " +
"Create an `untrusted` runtime in `runtimes` instead.",
CRIDefaultRuntime: "The `default_runtime` property of [plugins.\"io.containerd.grpc.v1.cri\".containerd] is deprecated since containerd v1.3 and will be removed in containerd v2.0. " +
"Use `default_runtime_name` instead.",
CRIRuntimeEngine: "The `runtime_engine` property of [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.*] is deprecated since containerd v1.3 and will be removed in containerd v2.0. " +
"Use a v2 runtime and `options` instead.",
CRIRuntimeRoot: "The `runtime_root` property of [plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.*] is deprecated since containerd v1.3 and will be removed in containerd v2.0. " +
"Use a v2 runtime and `options.Root` instead.",
CRIRegistryMirrors: "The `mirrors` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0. " +
"Use `config_path` instead.",
CRIRegistryAuths: "The `auths` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.3 and will be removed in containerd v2.0." +
CRIRegistryAuths: "The `auths` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.3 and will be removed in containerd v2.0. " +
"Use `ImagePullSecrets` instead.",
CRIRegistryConfigs: "The `configs` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0." +
CRIRegistryConfigs: "The `configs` property of `[plugins.\"io.containerd.grpc.v1.cri\".registry]` is deprecated since containerd v1.5 and will be removed in containerd v2.0. " +
"Use `config_path` instead.",
CRIAPIV1Alpha2: "CRI API v1alpha2 is deprecated since containerd v1.7 and removed in containerd v2.0. Use CRI API v1 instead.",
AUFSSnapshotter: "The aufs snapshotter is deprecated since containerd v1.5 and removed in containerd v2.0. Use the overlay snapshotter instead.",
Expand Down