Remove support for config.toml version = 1
`version = 1` has been deprecated since containerd v1.5, and replaced by `version = 2`. Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
This commit is contained in:
parent
e735405c15
commit
a4d33a7848
@ -373,7 +373,7 @@ The deprecated features are shown in the following table:
|
||||
|----------------------------------------------------------------------------------|---------------------|----------------------------|------------------------------------------|
|
||||
| Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 ✅ | Use `io.containerd.runc.v2` |
|
||||
| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 ✅ | Use `io.containerd.runc.v2` |
|
||||
| config.toml `version = 1` | containerd v1.5 | containerd v2.0 | Use config.toml `version = 2` |
|
||||
| config.toml `version = 1` | containerd v1.5 | containerd v2.0 ✅ | Use config.toml `version = 2` |
|
||||
| Built-in `aufs` snapshotter | containerd v1.5 | containerd v2.0 ✅ | Use `overlayfs` snapshotter |
|
||||
| Container label `containerd.io/restart.logpath` | containerd v1.5 | containerd v2.0 ✅ | Use `containerd.io/restart.loguri` label |
|
||||
| `cri-containerd-*.tar.gz` release bundles | containerd v1.6 | containerd v2.0 | Use `containerd-*.tar.gz` bundles |
|
||||
|
@ -253,7 +253,7 @@ If you want to get the configuration combined with your configuration, run `cont
|
||||
|
||||
containerd has two configuration versions:
|
||||
- Version 2 (Recommended): Introduced in containerd 1.3.
|
||||
- Version 1 (Default): Introduced in containerd 1.0. Deprecated and will be removed in containerd 2.0.
|
||||
- Version 1 (Default): Introduced in containerd 1.0. Removed in containerd 2.0.
|
||||
|
||||
A configuration with Version 2 must have `version = 2` header, and must have
|
||||
fully qualified plugin IDs in the `[plugins]` section:
|
||||
|
@ -17,13 +17,13 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/imdario/mergo"
|
||||
"github.com/pelletier/go-toml"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/plugin"
|
||||
@ -97,11 +97,14 @@ func (c *Config) GetVersion() int {
|
||||
|
||||
// ValidateV2 validates the config for a v2 file
|
||||
func (c *Config) ValidateV2() error {
|
||||
version := c.GetVersion()
|
||||
if version < 2 {
|
||||
logrus.Warnf("containerd config version `%d` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, "+
|
||||
"see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header", version)
|
||||
return nil
|
||||
switch version := c.GetVersion(); version {
|
||||
case 1:
|
||||
return errors.New("containerd config version `1` is no longer supported since containerd v2.0, please switch to version `2`, " +
|
||||
"see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header")
|
||||
case 2:
|
||||
// NOP
|
||||
default:
|
||||
return fmt.Errorf("expected containerd config version `2`, got `%d`", version)
|
||||
}
|
||||
for _, p := range c.DisabledPlugins {
|
||||
if !strings.HasPrefix(p, "io.containerd.") || len(strings.SplitN(p, ".", 4)) < 4 {
|
||||
@ -171,9 +174,6 @@ type ProxyPlugin struct {
|
||||
// Decode unmarshals a plugin specific configuration by plugin id
|
||||
func (c *Config) Decode(p *plugin.Registration) (interface{}, error) {
|
||||
id := p.URI()
|
||||
if c.GetVersion() == 1 {
|
||||
id = p.ID
|
||||
}
|
||||
data, ok := c.Plugins[id]
|
||||
if !ok {
|
||||
return p.Config, nil
|
||||
@ -313,18 +313,6 @@ func mergeConfig(to, from *Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// V1DisabledFilter matches based on ID
|
||||
func V1DisabledFilter(list []string) plugin.DisableFilter {
|
||||
set := make(map[string]struct{}, len(list))
|
||||
for _, l := range list {
|
||||
set[l] = struct{}{}
|
||||
}
|
||||
return func(r *plugin.Registration) bool {
|
||||
_, ok := set[r.ID]
|
||||
return ok
|
||||
}
|
||||
}
|
||||
|
||||
// V2DisabledFilter matches based on URI
|
||||
func V2DisabledFilter(list []string) plugin.DisableFilter {
|
||||
set := make(map[string]struct{}, len(list))
|
||||
|
@ -226,10 +226,5 @@ func TestDecodePluginInV1Config(t *testing.T) {
|
||||
|
||||
var out Config
|
||||
err = LoadConfig(path, &out)
|
||||
assert.NoError(t, err)
|
||||
|
||||
pluginConfig := map[string]interface{}{}
|
||||
_, err = out.Decode(&plugin.Registration{ID: "linux", Config: &pluginConfig})
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, true, pluginConfig["shim_debug"])
|
||||
assert.ErrorContains(t, err, "config version `1` is no longer supported")
|
||||
}
|
||||
|
@ -202,10 +202,6 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
||||
}
|
||||
for _, p := range plugins {
|
||||
id := p.URI()
|
||||
reqID := id
|
||||
if config.GetVersion() == 1 {
|
||||
reqID = p.ID
|
||||
}
|
||||
log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id)
|
||||
|
||||
initContext := plugin.NewContext(
|
||||
@ -239,13 +235,13 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
||||
} else {
|
||||
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
|
||||
}
|
||||
if _, ok := required[reqID]; ok {
|
||||
if _, ok := required[id]; ok {
|
||||
return nil, fmt.Errorf("load required plugin %s: %w", id, err)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
delete(required, reqID)
|
||||
delete(required, id)
|
||||
// check for grpc services that should be registered with the server
|
||||
if src, ok := instance.(grpcService); ok {
|
||||
grpcServices = append(grpcServices, src)
|
||||
@ -433,9 +429,6 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
|
||||
}
|
||||
|
||||
filter := srvconfig.V2DisabledFilter
|
||||
if config.GetVersion() == 1 {
|
||||
filter = srvconfig.V1DisabledFilter
|
||||
}
|
||||
// return the ordered graph for plugins
|
||||
return plugin.Graph(filter(config.DisabledPlugins)), nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user