Skip to content

Commit 8c38975

Browse files
committed
cri: add deprecation warning for mirrors
Signed-off-by: Samuel Karp <[email protected]> (cherry picked from commit d7cb25d) Signed-off-by: Samuel Karp <[email protected]>
1 parent 1fbce40 commit 8c38975

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

pkg/cri/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,7 @@ func ValidatePluginConfig(ctx context.Context, c *PluginConfig) ([]deprecation.W
469469
if useConfigPath {
470470
return warnings, errors.New("`mirrors` cannot be set when `config_path` is provided")
471471
}
472+
warnings = append(warnings, deprecation.CRIRegistryMirrors)
472473
log.G(ctx).Warning("`mirrors` is deprecated, please use `config_path` instead")
473474
}
474475
var hasDeprecatedTLS bool

pkg/cri/config/config_test.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
"fmt"
2222
"testing"
2323

24-
"github.com/containerd/containerd/plugin"
2524
"github.com/stretchr/testify/assert"
2625

26+
"github.com/containerd/containerd/plugin"
27+
2728
"github.com/containerd/containerd/pkg/deprecation"
2829
)
2930

@@ -371,6 +372,37 @@ func TestValidateConfig(t *testing.T) {
371372
},
372373
expectedErr: "`configs.tls` cannot be set when `config_path` is provided",
373374
},
375+
"deprecated mirrors": {
376+
config: &PluginConfig{
377+
ContainerdConfig: ContainerdConfig{
378+
DefaultRuntimeName: RuntimeDefault,
379+
Runtimes: map[string]Runtime{
380+
RuntimeDefault: {},
381+
},
382+
},
383+
Registry: Registry{
384+
Mirrors: map[string]Mirror{
385+
"example.com": {},
386+
},
387+
},
388+
},
389+
expected: &PluginConfig{
390+
ContainerdConfig: ContainerdConfig{
391+
DefaultRuntimeName: RuntimeDefault,
392+
Runtimes: map[string]Runtime{
393+
RuntimeDefault: {
394+
SandboxMode: string(ModePodSandbox),
395+
},
396+
},
397+
},
398+
Registry: Registry{
399+
Mirrors: map[string]Mirror{
400+
"example.com": {},
401+
},
402+
},
403+
},
404+
warnings: []deprecation.Warning{deprecation.CRIRegistryMirrors},
405+
},
374406
"privileged_without_host_devices_all_devices_allowed without privileged_without_host_devices": {
375407
config: &PluginConfig{
376408
ContainerdConfig: ContainerdConfig{

pkg/deprecation/deprecation.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ const (
2525
PullSchema1Image Warning = Prefix + "pull-schema-1-image"
2626
// GoPluginLibrary is a warning for the use of dynamic library Go plugins
2727
GoPluginLibrary Warning = Prefix + "go-plugin-library"
28+
// CRIRegistryMirrors is a warning for the use of the `mirrors` property
29+
CRIRegistryMirrors Warning = Prefix + "cri-registry-mirrors"
2830
)
2931

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

3640
// Valid checks whether a given Warning is valid

0 commit comments

Comments
 (0)