Skip to content

Commit

Permalink
Add warning for CRIU config usage
Browse files Browse the repository at this point in the history
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
(cherry picked from commit 1fdefdd)
Signed-off-by: ruiwen-zhao <ruiwen@google.com>
  • Loading branch information
ruiwen-zhao committed Dec 14, 2023
1 parent 3dd1e88 commit f844746
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/cri/config/config.go
Expand Up @@ -396,6 +396,11 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
}
log.G(ctx).Warning("`runtime_root` is deprecated, please use runtime `options` instead")
}

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 != ""
Expand Down
27 changes: 27 additions & 0 deletions pkg/cri/config/config_test.go
Expand Up @@ -430,6 +430,33 @@ func TestValidateConfig(t *testing.T) {
},
warnings: []deprecation.Warning{deprecation.CRIRegistryConfigs},
},
"deprecated CRIU path": {
config: &PluginConfig{
ContainerdConfig: ContainerdConfig{
DefaultRuntimeName: RuntimeDefault,
Runtimes: map[string]Runtime{
RuntimeDefault: {
Options: map[string]interface{}{
"CriuPath": "/path/to/criu-binary",
},
},
},
},
},
expected: &PluginConfig{
ContainerdConfig: ContainerdConfig{
DefaultRuntimeName: RuntimeDefault,
Runtimes: map[string]Runtime{
RuntimeDefault: {
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)
Expand Down
4 changes: 4 additions & 0 deletions pkg/deprecation/deprecation.go
Expand Up @@ -39,6 +39,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{
Expand All @@ -55,6 +57,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
Expand Down

0 comments on commit f844746

Please sign in to comment.