summaryrefslogtreecommitdiffhomepage
path: root/test/root/crictl_test.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2021-10-25 13:13:56 -0700
committergVisor bot <gvisor-bot@google.com>2021-10-25 13:17:25 -0700
commit9262ea47a5d93d44b14f298663982b75ed2e4898 (patch)
treea7f1c8e67d9c3180e30f309186e63a83aa099449 /test/root/crictl_test.go
parent7c267106d1d7d162d6204e6b0402d3063b1bf468 (diff)
Add support for containerd 1.5
"cri.runtimeoptions.v1" moved to "runtimeoptions.v1" and containerd configuration format version 2 is required. Updates #6449 PiperOrigin-RevId: 405474653
Diffstat (limited to 'test/root/crictl_test.go')
-rw-r--r--test/root/crictl_test.go40
1 files changed, 34 insertions, 6 deletions
diff --git a/test/root/crictl_test.go b/test/root/crictl_test.go
index c26dc8577..0378d851e 100644
--- a/test/root/crictl_test.go
+++ b/test/root/crictl_test.go
@@ -270,10 +270,11 @@ func TestHomeDir(t *testing.T) {
const containerdRuntime = "runsc"
-// Template is the containerd configuration file that configures containerd with
-// the gVisor shim, Note that the v2 shim binary name must be
-// containerd-shim-<runtime>-v1.
-const template = `
+// containerdConfigv14 is the containerd (1.4-) configuration file that
+// configures the gVisor shim.
+//
+// Note that the v2 shim binary name must be containerd-shim-<runtime>-v1.
+const containerdConfigv14 = `
disabled_plugins = ["restart"]
[plugins.cri]
disable_tcp_service = true
@@ -285,6 +286,25 @@ disabled_plugins = ["restart"]
TypeUrl = "io.containerd.` + containerdRuntime + `.v1.options"
`
+// containerdConfig is the containerd (1.5+) configuration file that
+// configures the gVisor shim.
+//
+// Note that the v2 shim binary name must be containerd-shim-<runtime>-v1.
+const containerdConfig = `
+version=2
+disabled_plugins = ["io.containerd.internal.v1.restart"]
+[plugins."io.containerd.grpc.v1.cri"]
+ disable_tcp_service = true
+[plugins."io.containerd.runtime.v1.linux"]
+ shim_debug = true
+[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc]
+ runtime_type = "io.containerd.runc.v2"
+[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.` + containerdRuntime + `]
+ runtime_type = "io.containerd.` + containerdRuntime + `.v1"
+[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.` + containerdRuntime + `.options]
+ TypeUrl = "io.containerd.` + containerdRuntime + `.v1.options"
+`
+
// setup sets up before a test. Specifically it:
// * Creates directories and a socket for containerd to utilize.
// * Runs containerd and waits for it to reach a "ready" state for testing.
@@ -362,8 +382,9 @@ func setup(t *testing.T) (*criutil.Crictl, func(), error) {
t.Logf("Using PATH: %v", modifiedPath)
// Generate the configuration for the test.
- t.Logf("Using config: %s", template)
- configFile, configCleanup, err := testutil.WriteTmpFile("containerd-config", template)
+ config := getContainerdConfig(major, minor)
+ t.Logf("Using config: %s", config)
+ configFile, configCleanup, err := testutil.WriteTmpFile("containerd-config", config)
if err != nil {
t.Fatalf("failed to write containerd config")
}
@@ -474,3 +495,10 @@ func getContainerd() string {
}
return "/usr/bin/containerd"
}
+
+func getContainerdConfig(major, minor uint64) string {
+ if major == 1 && minor <= 4 {
+ return containerdConfigv14
+ }
+ return containerdConfig
+}