@@ -24,6 +24,8 @@ import (
2424 "time"
2525
2626 "github.com/containerd/log"
27+
28+ "github.com/containerd/containerd/v2/pkg/deprecation"
2729)
2830
2931type SandboxControllerMode string
@@ -365,22 +367,23 @@ const (
365367)
366368
367369// ValidatePluginConfig validates the given plugin configuration.
368- func ValidatePluginConfig (ctx context.Context , c * PluginConfig ) error {
370+ func ValidatePluginConfig (ctx context.Context , c * PluginConfig ) ([]deprecation.Warning , error ) {
371+ var warnings []deprecation.Warning
369372 if c .ContainerdConfig .Runtimes == nil {
370373 c .ContainerdConfig .Runtimes = make (map [string ]Runtime )
371374 }
372375
373376 // Validation for default_runtime_name
374377 if c .ContainerdConfig .DefaultRuntimeName == "" {
375- return errors .New ("`default_runtime_name` is empty" )
378+ return warnings , errors .New ("`default_runtime_name` is empty" )
376379 }
377380 if _ , ok := c .ContainerdConfig .Runtimes [c .ContainerdConfig .DefaultRuntimeName ]; ! ok {
378- return fmt .Errorf ("no corresponding runtime configured in `containerd.runtimes` for `containerd` `default_runtime_name = \" %s\" " , c .ContainerdConfig .DefaultRuntimeName )
381+ return warnings , fmt .Errorf ("no corresponding runtime configured in `containerd.runtimes` for `containerd` `default_runtime_name = \" %s\" " , c .ContainerdConfig .DefaultRuntimeName )
379382 }
380383
381384 for k , r := range c .ContainerdConfig .Runtimes {
382385 if ! r .PrivilegedWithoutHostDevices && r .PrivilegedWithoutHostDevicesAllDevicesAllowed {
383- return errors .New ("`privileged_without_host_devices_all_devices_allowed` requires `privileged_without_host_devices` to be enabled" )
386+ return warnings , errors .New ("`privileged_without_host_devices_all_devices_allowed` requires `privileged_without_host_devices` to be enabled" )
384387 }
385388 // If empty, use default podSandbox mode
386389 if len (r .Sandboxer ) == 0 {
@@ -392,7 +395,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
392395 useConfigPath := c .Registry .ConfigPath != ""
393396 if len (c .Registry .Mirrors ) > 0 {
394397 if useConfigPath {
395- return errors .New ("`mirrors` cannot be set when `config_path` is provided" )
398+ return warnings , errors .New ("`mirrors` cannot be set when `config_path` is provided" )
396399 }
397400 log .G (ctx ).Warning ("`mirrors` is deprecated, please use `config_path` instead" )
398401 }
@@ -406,7 +409,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
406409 auth := auth
407410 u , err := url .Parse (endpoint )
408411 if err != nil {
409- return fmt .Errorf ("failed to parse registry url %q from `registry.auths`: %w" , endpoint , err )
412+ return warnings , fmt .Errorf ("failed to parse registry url %q from `registry.auths`: %w" , endpoint , err )
410413 }
411414 if u .Scheme != "" {
412415 // Do not include the scheme in the new registry config.
@@ -422,22 +425,22 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) error {
422425 // Validation for stream_idle_timeout
423426 if c .StreamIdleTimeout != "" {
424427 if _ , err := time .ParseDuration (c .StreamIdleTimeout ); err != nil {
425- return fmt .Errorf ("invalid stream idle timeout: %w" , err )
428+ return warnings , fmt .Errorf ("invalid stream idle timeout: %w" , err )
426429 }
427430 }
428431
429432 // Validation for image_pull_progress_timeout
430433 if c .ImagePullProgressTimeout != "" {
431434 if _ , err := time .ParseDuration (c .ImagePullProgressTimeout ); err != nil {
432- return fmt .Errorf ("invalid image pull progress timeout: %w" , err )
435+ return warnings , fmt .Errorf ("invalid image pull progress timeout: %w" , err )
433436 }
434437 }
435438
436439 // Validation for drain_exec_sync_io_timeout
437440 if c .DrainExecSyncIOTimeout != "" {
438441 if _ , err := time .ParseDuration (c .DrainExecSyncIOTimeout ); err != nil {
439- return fmt .Errorf ("invalid `drain_exec_sync_io_timeout`: %w" , err )
442+ return warnings , fmt .Errorf ("invalid `drain_exec_sync_io_timeout`: %w" , err )
440443 }
441444 }
442- return nil
445+ return warnings , nil
443446}
0 commit comments