Switch all our tests to version 2
Also warn when someone uses version 1 Signed-off-by: Davanum Srinivas <davanum@gmail.com>
This commit is contained in:
parent
2a2d779594
commit
9ad087947d
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@ -427,8 +427,9 @@ jobs:
|
|||||||
BDIR="$(mktemp -d -p $PWD)"
|
BDIR="$(mktemp -d -p $PWD)"
|
||||||
mkdir -p ${BDIR}/{root,state}
|
mkdir -p ${BDIR}/{root,state}
|
||||||
cat > ${BDIR}/config.toml <<EOF
|
cat > ${BDIR}/config.toml <<EOF
|
||||||
[plugins.cri.containerd.default_runtime]
|
version = 2
|
||||||
runtime_type = "${TEST_RUNTIME}"
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
|
||||||
|
runtime_type = "${TEST_RUNTIME}"
|
||||||
EOF
|
EOF
|
||||||
sudo ls /etc/cni/net.d
|
sudo ls /etc/cni/net.d
|
||||||
sudo PATH=$PATH BDIR=$BDIR /usr/local/bin/containerd -a ${BDIR}/c.sock --config ${BDIR}/config.toml --root ${BDIR}/root --state ${BDIR}/state --log-level debug &> ${BDIR}/containerd-cri.log &
|
sudo PATH=$PATH BDIR=$BDIR /usr/local/bin/containerd -a ${BDIR}/c.sock --config ${BDIR}/config.toml --root ${BDIR}/root --state ${BDIR}/state --log-level debug &> ${BDIR}/containerd-cri.log &
|
||||||
|
@ -294,7 +294,8 @@ The daemon's configuration file, commonly located in `/etc/containerd/config.tom
|
|||||||
is versioned and backwards compatible. The `version` field in the config
|
is versioned and backwards compatible. The `version` field in the config
|
||||||
file specifies the config's version. If no version number is specified inside
|
file specifies the config's version. If no version number is specified inside
|
||||||
the config file then it is assumed to be a version 1 config and parsed as such.
|
the config file then it is assumed to be a version 1 config and parsed as such.
|
||||||
Use `version = 2` to enable version 2 config.
|
Please use `version = 2` to enable version 2 config as version 1 has been
|
||||||
|
deprecated.
|
||||||
|
|
||||||
### Not Covered
|
### Not Covered
|
||||||
|
|
||||||
@ -324,3 +325,4 @@ 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 |
|
| Runtime V1 API and implementation (`io.containerd.runtime.v1.linux`) | containerd v1.4 | containerd v2.0 |
|
||||||
| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 |
|
| Runc V1 implementation of Runtime V2 (`io.containerd.runc.v1`) | containerd v1.4 | containerd v2.0 |
|
||||||
|
| config.toml `version = 1` | containerd v1.5 | containerd v2.0 |
|
||||||
|
@ -120,7 +120,7 @@ var configCommand = cli.Command{
|
|||||||
|
|
||||||
func platformAgnosticDefaultConfig() *srvconfig.Config {
|
func platformAgnosticDefaultConfig() *srvconfig.Config {
|
||||||
return &srvconfig.Config{
|
return &srvconfig.Config{
|
||||||
Version: 1,
|
Version: 2,
|
||||||
Root: defaults.DefaultRootDir,
|
Root: defaults.DefaultRootDir,
|
||||||
State: defaults.DefaultStateDir,
|
State: defaults.DefaultStateDir,
|
||||||
GRPC: srvconfig.GRPCConfig{
|
GRPC: srvconfig.GRPCConfig{
|
||||||
|
@ -503,12 +503,12 @@ func createShimDebugConfig() string {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
if _, err := f.WriteString("version = 1\n"); err != nil {
|
if _, err := f.WriteString("version = 2\n"); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
|
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, err := f.WriteString("[plugins.linux]\n\tshim_debug = true\n"); err != nil {
|
if _, err := f.WriteString("[plugins.\"io.containerd.runtime.v1.linux\"]\n\tshim_debug = true\n"); err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
|
fmt.Fprintf(os.Stderr, "Failed to write to config file %s: %s\n", f.Name(), err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
@ -129,9 +129,9 @@ func TestDaemonRuntimeRoot(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
configTOML := `
|
configTOML := `
|
||||||
version = 1
|
version = 2
|
||||||
[plugins]
|
[plugins]
|
||||||
[plugins.cri]
|
[plugins."io.containerd.grpc.v1.cri"]
|
||||||
stream_server_port = "0"
|
stream_server_port = "0"
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ func TestDaemonCustomCgroup(t *testing.T) {
|
|||||||
|
|
||||||
customCgroup := fmt.Sprintf("%d", time.Now().Nanosecond())
|
customCgroup := fmt.Sprintf("%d", time.Now().Nanosecond())
|
||||||
configTOML := `
|
configTOML := `
|
||||||
version = 1
|
version = 2
|
||||||
[cgroup]
|
[cgroup]
|
||||||
path = "` + customCgroup + `"`
|
path = "` + customCgroup + `"`
|
||||||
|
|
||||||
|
@ -30,14 +30,15 @@ if [ -z "${CONTAINERD_CONFIG_FILE}" ]; then
|
|||||||
truncate --size 0 "${config_file}"
|
truncate --size 0 "${config_file}"
|
||||||
if command -v sestatus >/dev/null 2>&1; then
|
if command -v sestatus >/dev/null 2>&1; then
|
||||||
cat >>${config_file} <<EOF
|
cat >>${config_file} <<EOF
|
||||||
[plugins.cri]
|
version=2
|
||||||
|
[plugins."io.containerd.grpc.v1.cri"]
|
||||||
enable_selinux = true
|
enable_selinux = true
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
if [ -n "${CONTAINERD_RUNTIME}" ]; then
|
if [ -n "${CONTAINERD_RUNTIME}" ]; then
|
||||||
cat >>${config_file} <<EOF
|
cat >>${config_file} <<EOF
|
||||||
[plugins.cri.containerd.default_runtime]
|
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
|
||||||
runtime_type="${CONTAINERD_RUNTIME}"
|
runtime_type = "${CONTAINERD_RUNTIME}"
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
CONTAINERD_CONFIG_FILE="${config_file}"
|
CONTAINERD_CONFIG_FILE="${config_file}"
|
||||||
|
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
"github.com/pelletier/go-toml"
|
"github.com/pelletier/go-toml"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/containerd/containerd/errdefs"
|
"github.com/containerd/containerd/errdefs"
|
||||||
"github.com/containerd/containerd/plugin"
|
"github.com/containerd/containerd/plugin"
|
||||||
@ -94,8 +95,9 @@ 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 {
|
||||||
if c.GetVersion() != 2 {
|
version := c.GetVersion()
|
||||||
return nil
|
if version < 2 {
|
||||||
|
logrus.Warnf("deprecated version : `%d`, please switch to version `2`", version)
|
||||||
}
|
}
|
||||||
for _, p := range c.DisabledPlugins {
|
for _, p := range c.DisabledPlugins {
|
||||||
if len(strings.Split(p, ".")) < 4 {
|
if len(strings.Split(p, ".")) < 4 {
|
||||||
@ -258,7 +260,11 @@ func LoadConfig(path string, out *Config) error {
|
|||||||
out.Imports = append(out.Imports, path)
|
out.Imports = append(out.Imports, path)
|
||||||
}
|
}
|
||||||
|
|
||||||
return out.ValidateV2()
|
err := out.ValidateV2()
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to load TOML from %s", path)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// loadConfigFile decodes a TOML file at the given path
|
// loadConfigFile decodes a TOML file at the given path
|
||||||
|
@ -185,8 +185,8 @@ imports = ["data1.toml", "data2.toml"]
|
|||||||
|
|
||||||
func TestDecodePlugin(t *testing.T) {
|
func TestDecodePlugin(t *testing.T) {
|
||||||
data := `
|
data := `
|
||||||
version = 1
|
version = 2
|
||||||
[plugins.linux]
|
[plugins."io.containerd.runtime.v1.linux"]
|
||||||
shim_debug = true
|
shim_debug = true
|
||||||
`
|
`
|
||||||
|
|
||||||
@ -203,7 +203,7 @@ version = 1
|
|||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
pluginConfig := map[string]interface{}{}
|
pluginConfig := map[string]interface{}{}
|
||||||
_, err = out.Decode(&plugin.Registration{ID: "linux", Config: &pluginConfig})
|
_, err = out.Decode(&plugin.Registration{Type: "io.containerd.runtime.v1", ID: "linux", Config: &pluginConfig})
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
assert.Equal(t, true, pluginConfig["shim_debug"])
|
assert.Equal(t, true, pluginConfig["shim_debug"])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user