Skip to content

Commit

Permalink
cri: add deprecation warning for mirrors
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Karp <samuelkarp@google.com>
(cherry picked from commit d7cb25d)
Signed-off-by: Samuel Karp <samuelkarp@google.com>
  • Loading branch information
samuelkarp committed Nov 9, 2023
1 parent 878823f commit 455edca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/cri/config/config.go
Expand Up @@ -403,6 +403,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
if useConfigPath {
return warnings, errors.New("`mirrors` cannot be set when `config_path` is provided")
}
warnings = append(warnings, deprecation.CRIRegistryMirrors)
log.G(ctx).Warning("`mirrors` is deprecated, please use `config_path` instead")
}
var hasDeprecatedTLS bool
Expand Down
29 changes: 29 additions & 0 deletions pkg/cri/config/config_test.go
Expand Up @@ -363,6 +363,35 @@ func TestValidateConfig(t *testing.T) {
},
expectedErr: "`configs.tls` cannot be set when `config_path` is provided",
},
"deprecated mirrors": {
config: &PluginConfig{
ContainerdConfig: ContainerdConfig{
DefaultRuntimeName: RuntimeDefault,
Runtimes: map[string]Runtime{
RuntimeDefault: {},
},
},
Registry: Registry{
Mirrors: map[string]Mirror{
"example.com": {},
},
},
},
expected: &PluginConfig{
ContainerdConfig: ContainerdConfig{
DefaultRuntimeName: RuntimeDefault,
Runtimes: map[string]Runtime{
RuntimeDefault: {},
},
},
Registry: Registry{
Mirrors: map[string]Mirror{
"example.com": {},
},
},
},
warnings: []deprecation.Warning{deprecation.CRIRegistryMirrors},
},
} {
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 @@ -25,12 +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"
// CRIRegistryMirrors is a warning for the use of the `mirrors` property
CRIRegistryMirrors Warning = Prefix + "cri-registry-mirrors"
)

var messages = map[Warning]string{
PullSchema1Image: "Schema 1 images will be deprecated in containerd v1.7 and removed in containerd v2.0. " +
`Since containerd v1.6.25, schema 1 images are identified by the "io.containerd.image/converted-docker-schema1" label.`,
GoPluginLibrary: "Dynamically-linked Go plugins as containerd runtimes are deprecated since 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." +
"Use `config_path` instead.",
}

// Valid checks whether a given Warning is valid
Expand Down

0 comments on commit 455edca

Please sign in to comment.