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` |
|
| 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` |
|
| 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 |
|
| 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 |
|
| 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 |
|
| `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:
|
containerd has two configuration versions:
|
||||||
- Version 2 (Recommended): Introduced in containerd 1.3.
|
- 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
|
A configuration with Version 2 must have `version = 2` header, and must have
|
||||||
fully qualified plugin IDs in the `[plugins]` section:
|
fully qualified plugin IDs in the `[plugins]` section:
|
||||||
|
@ -17,13 +17,13 @@
|
|||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -97,11 +97,14 @@ func (c *Config) GetVersion() int {
|
|||||||
|
|
||||||
// ValidateV2 validates the config for a v2 file
|
// ValidateV2 validates the config for a v2 file
|
||||||
func (c *Config) ValidateV2() error {
|
func (c *Config) ValidateV2() error {
|
||||||
version := c.GetVersion()
|
switch version := c.GetVersion(); version {
|
||||||
if version < 2 {
|
case 1:
|
||||||
logrus.Warnf("containerd config version `%d` has been deprecated and will be removed in containerd v2.0, please switch to version `2`, "+
|
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", version)
|
"see https://github.com/containerd/containerd/blob/main/docs/PLUGINS.md#version-header")
|
||||||
return nil
|
case 2:
|
||||||
|
// NOP
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("expected containerd config version `2`, got `%d`", version)
|
||||||
}
|
}
|
||||||
for _, p := range c.DisabledPlugins {
|
for _, p := range c.DisabledPlugins {
|
||||||
if !strings.HasPrefix(p, "io.containerd.") || len(strings.SplitN(p, ".", 4)) < 4 {
|
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
|
// Decode unmarshals a plugin specific configuration by plugin id
|
||||||
func (c *Config) Decode(p *plugin.Registration) (interface{}, error) {
|
func (c *Config) Decode(p *plugin.Registration) (interface{}, error) {
|
||||||
id := p.URI()
|
id := p.URI()
|
||||||
if c.GetVersion() == 1 {
|
|
||||||
id = p.ID
|
|
||||||
}
|
|
||||||
data, ok := c.Plugins[id]
|
data, ok := c.Plugins[id]
|
||||||
if !ok {
|
if !ok {
|
||||||
return p.Config, nil
|
return p.Config, nil
|
||||||
@ -313,18 +313,6 @@ func mergeConfig(to, from *Config) error {
|
|||||||
return nil
|
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
|
// V2DisabledFilter matches based on URI
|
||||||
func V2DisabledFilter(list []string) plugin.DisableFilter {
|
func V2DisabledFilter(list []string) plugin.DisableFilter {
|
||||||
set := make(map[string]struct{}, len(list))
|
set := make(map[string]struct{}, len(list))
|
||||||
|
@ -226,10 +226,5 @@ func TestDecodePluginInV1Config(t *testing.T) {
|
|||||||
|
|
||||||
var out Config
|
var out Config
|
||||||
err = LoadConfig(path, &out)
|
err = LoadConfig(path, &out)
|
||||||
assert.NoError(t, err)
|
assert.ErrorContains(t, err, "config version `1` is no longer supported")
|
||||||
|
|
||||||
pluginConfig := map[string]interface{}{}
|
|
||||||
_, err = out.Decode(&plugin.Registration{ID: "linux", Config: &pluginConfig})
|
|
||||||
assert.NoError(t, err)
|
|
||||||
assert.Equal(t, true, pluginConfig["shim_debug"])
|
|
||||||
}
|
}
|
||||||
|
@ -202,10 +202,6 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
|||||||
}
|
}
|
||||||
for _, p := range plugins {
|
for _, p := range plugins {
|
||||||
id := p.URI()
|
id := p.URI()
|
||||||
reqID := id
|
|
||||||
if config.GetVersion() == 1 {
|
|
||||||
reqID = p.ID
|
|
||||||
}
|
|
||||||
log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id)
|
log.G(ctx).WithField("type", p.Type).Infof("loading plugin %q...", id)
|
||||||
|
|
||||||
initContext := plugin.NewContext(
|
initContext := plugin.NewContext(
|
||||||
@ -239,13 +235,13 @@ func New(ctx context.Context, config *srvconfig.Config) (*Server, error) {
|
|||||||
} else {
|
} else {
|
||||||
log.G(ctx).WithError(err).Warnf("failed to load plugin %s", id)
|
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)
|
return nil, fmt.Errorf("load required plugin %s: %w", id, err)
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(required, reqID)
|
delete(required, id)
|
||||||
// check for grpc services that should be registered with the server
|
// check for grpc services that should be registered with the server
|
||||||
if src, ok := instance.(grpcService); ok {
|
if src, ok := instance.(grpcService); ok {
|
||||||
grpcServices = append(grpcServices, src)
|
grpcServices = append(grpcServices, src)
|
||||||
@ -433,9 +429,6 @@ func LoadPlugins(ctx context.Context, config *srvconfig.Config) ([]*plugin.Regis
|
|||||||
}
|
}
|
||||||
|
|
||||||
filter := srvconfig.V2DisabledFilter
|
filter := srvconfig.V2DisabledFilter
|
||||||
if config.GetVersion() == 1 {
|
|
||||||
filter = srvconfig.V1DisabledFilter
|
|
||||||
}
|
|
||||||
// return the ordered graph for plugins
|
// return the ordered graph for plugins
|
||||||
return plugin.Graph(filter(config.DisabledPlugins)), nil
|
return plugin.Graph(filter(config.DisabledPlugins)), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user