From 1fdefdd2242fcf704a11f1d6b5149e056ce98ed3 Mon Sep 17 00:00:00 2001 From: ruiwen-zhao Date: Wed, 6 Dec 2023 20:45:53 +0000 Subject: [PATCH] Add warning for CRIU config usage Signed-off-by: ruiwen-zhao --- pkg/cri/config/config.go | 5 +++++ pkg/cri/config/config_test.go | 29 +++++++++++++++++++++++++++++ pkg/deprecation/deprecation.go | 4 ++++ 3 files changed, 38 insertions(+) diff --git a/pkg/cri/config/config.go b/pkg/cri/config/config.go index 49dce02664..4c9d6c22fa 100644 --- a/pkg/cri/config/config.go +++ b/pkg/cri/config/config.go @@ -491,6 +491,11 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W r.SandboxMode = string(ModePodSandbox) c.ContainerdConfig.Runtimes[k] = r } + + if p, ok := r.Options["CriuPath"].(string); ok && p != "" { + log.G(ctx).Warning("`CriuPath` is deprecated, please use a criu binary in $PATH instead.") + warnings = append(warnings, deprecation.CRICRIUPath) + } } useConfigPath := c.Registry.ConfigPath != "" diff --git a/pkg/cri/config/config_test.go b/pkg/cri/config/config_test.go index d8a5ce9365..979f083c36 100644 --- a/pkg/cri/config/config_test.go +++ b/pkg/cri/config/config_test.go @@ -477,6 +477,35 @@ func TestValidateConfig(t *testing.T) { }, expectedErr: "invalid `drain_exec_sync_io_timeout`", }, + "deprecated CRIU path": { + config: &PluginConfig{ + ContainerdConfig: ContainerdConfig{ + DefaultRuntimeName: RuntimeDefault, + Runtimes: map[string]Runtime{ + RuntimeDefault: { + SandboxMode: string(ModePodSandbox), + Options: map[string]interface{}{ + "CriuPath": "/path/to/criu-binary", + }, + }, + }, + }, + }, + expected: &PluginConfig{ + ContainerdConfig: ContainerdConfig{ + DefaultRuntimeName: RuntimeDefault, + Runtimes: map[string]Runtime{ + RuntimeDefault: { + SandboxMode: string(ModePodSandbox), + Options: map[string]interface{}{ + "CriuPath": "/path/to/criu-binary", + }, + }, + }, + }, + }, + warnings: []deprecation.Warning{deprecation.CRICRIUPath}, + }, } { t.Run(desc, func(t *testing.T) { w, err := ValidatePluginConfig(context.Background(), test.config) diff --git a/pkg/deprecation/deprecation.go b/pkg/deprecation/deprecation.go index 91d3952c62..9b57a3e820 100644 --- a/pkg/deprecation/deprecation.go +++ b/pkg/deprecation/deprecation.go @@ -49,6 +49,8 @@ const ( RuntimeV1 Warning = Prefix + "runtime-v1" // RuntimeRuncV1 is a warning for the io.containerd.runc.v1 runtime RuntimeRuncV1 Warning = Prefix + "runtime-runc-v1" + // CRICRIUPath is a warning for the use of the `CriuPath` property + CRICRIUPath Warning = Prefix + "cri-criu-path" ) var messages = map[Warning]string{ @@ -75,6 +77,8 @@ var messages = map[Warning]string{ AUFSSnapshotter: "The aufs snapshotter is deprecated since containerd v1.5 and removed in containerd v2.0. Use the overlay snapshotter instead.", RuntimeV1: "The `io.containerd.runtime.v1.linux` runtime is deprecated since containerd v1.4 and removed in containerd v2.0. Use the `io.containerd.runc.v2` runtime instead.", RuntimeRuncV1: "The `io.containerd.runc.v1` runtime is deprecated since containerd v1.4 and removed in containerd v2.0. Use the `io.containerd.runc.v2` runtime instead.", + CRICRIUPath: "The `CriuPath` property of `[plugins.\"io.containerd.grpc.v1.cri\".containerd.runtimes.*.options]` is deprecated since containerd v1.7 and will be removed in containerd v2.0. " + + "Use a criu binary in $PATH instead.", } // Valid checks whether a given Warning is valid