Remove v1 runctypes

Signed-off-by: Maksym Pavlenko <pavlenko.maksym@gmail.com>
This commit is contained in:
Maksym Pavlenko
2023-03-13 14:12:29 -07:00
parent c50a3ef043
commit 07c2ae12e1
31 changed files with 106 additions and 2178 deletions

View File

@@ -32,7 +32,6 @@ import (
. "github.com/containerd/containerd"
"github.com/containerd/containerd/cio"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/plugin"
)
const (
@@ -48,9 +47,6 @@ func TestCheckpointRestorePTY(t *testing.T) {
t.Fatal(err)
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip()
}
var (
ctx, cancel = testContext(t)
@@ -174,9 +170,6 @@ func TestCheckpointRestore(t *testing.T) {
t.Fatal(err)
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip()
}
var (
ctx, cancel = testContext(t)
@@ -264,9 +257,6 @@ func TestCheckpointRestoreNewContainer(t *testing.T) {
t.Fatal(err)
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip()
}
id := t.Name()
ctx, cancel := testContext(t)
@@ -354,9 +344,6 @@ func TestCheckpointLeaveRunning(t *testing.T) {
t.Fatal(err)
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip()
}
var (
ctx, cancel = testContext(t)
@@ -538,9 +525,6 @@ func TestCheckpointOnPauseStatus(t *testing.T) {
t.Fatal(err)
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip()
}
var (
ctx, cancel = testContext(t)

View File

@@ -39,7 +39,6 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime/linux/runctypes"
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/containerd/containerd/sys"
"github.com/opencontainers/runtime-spec/specs-go"
@@ -415,8 +414,6 @@ func writeToFile(t *testing.T, filePath, message string) {
func getLogDirPath(runtimeVersion, id string) string {
switch runtimeVersion {
case "v1":
return filepath.Join(defaultRoot, plugin.RuntimeLinuxV1, testNamespace, id)
case "v2":
return filepath.Join(defaultState, "io.containerd.runtime.v2.task", testNamespace, id)
default:
@@ -1005,49 +1002,6 @@ func TestDaemonRestartWithRunningShim(t *testing.T) {
}
}
func TestContainerRuntimeOptionsv1(t *testing.T) {
t.Parallel()
client, err := newClient(t, address)
if err != nil {
t.Fatal(err)
}
defer client.Close()
var (
image Image
ctx, cancel = testContext(t)
id = t.Name()
)
defer cancel()
image, err = client.GetImage(ctx, testImage)
if err != nil {
t.Fatal(err)
}
container, err := client.NewContainer(
ctx, id,
WithNewSnapshot(id, image),
WithNewSpec(oci.WithImageConfig(image), withExitStatus(7)),
WithRuntime(plugin.RuntimeLinuxV1, &runctypes.RuncOptions{Runtime: "no-runc"}),
)
if err != nil {
t.Fatal(err)
}
defer container.Delete(ctx, WithSnapshotCleanup)
task, err := container.NewTask(ctx, empty())
if err == nil {
t.Errorf("task creation should have failed")
task.Delete(ctx)
return
}
if !strings.Contains(err.Error(), `"no-runc"`) {
t.Errorf("task creation should have failed because of lack of executable. Instead failed with: %v", err.Error())
}
}
func TestContainerRuntimeOptionsv2(t *testing.T) {
t.Parallel()
@@ -1073,7 +1027,7 @@ func TestContainerRuntimeOptionsv2(t *testing.T) {
ctx, id,
WithNewSnapshot(id, image),
WithNewSpec(oci.WithImageConfig(image), withExitStatus(7)),
WithRuntime(plugin.RuntimeRuncV1, &options.Options{BinaryName: "no-runc"}),
WithRuntime(plugin.RuntimeRuncV2, &options.Options{BinaryName: "no-runc"}),
)
if err != nil {
t.Fatal(err)
@@ -1161,17 +1115,9 @@ func testUserNamespaces(t *testing.T, readonlyRootFS bool) {
}
defer container.Delete(ctx, WithSnapshotCleanup)
var copts interface{}
if CheckRuntime(client.Runtime(), "io.containerd.runc") {
copts = &options.Options{
IoUid: 1000,
IoGid: 2000,
}
} else {
copts = &runctypes.CreateOptions{
IoUid: 1000,
IoGid: 2000,
}
copts := &options.Options{
IoUid: 1000,
IoGid: 2000,
}
task, err := container.NewTask(ctx, cio.NewCreator(cio.WithStdio), func(_ context.Context, client *Client, r *TaskInfo) error {

View File

@@ -39,7 +39,6 @@ import (
"github.com/containerd/containerd/namespaces"
"github.com/containerd/containerd/oci"
"github.com/containerd/containerd/platforms"
"github.com/containerd/containerd/plugin"
gogotypes "github.com/containerd/containerd/protobuf/types"
_ "github.com/containerd/containerd/runtime"
"github.com/containerd/containerd/runtime/v2/runc/options"
@@ -670,10 +669,6 @@ func TestKillContainerDeletedByRunc(t *testing.T) {
}
defer client.Close()
if client.Runtime() == plugin.RuntimeLinuxV1 {
t.Skip("test relies on runtime v2")
}
var (
image Image
ctx, cancel = testContext(t)

View File

@@ -55,7 +55,7 @@ version = 2
}
id := t.Name()
container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withProcessArgs("top")), WithRuntime(plugin.RuntimeRuncV1, &options.Options{
container, err := client.NewContainer(ctx, id, WithNewSnapshot(id, image), WithNewSpec(oci.WithImageConfig(image), withProcessArgs("top")), WithRuntime(plugin.RuntimeRuncV2, &options.Options{
Root: runtimeRoot,
}))
if err != nil {

View File

@@ -1,64 +0,0 @@
//go:build !windows
/*
Copyright The containerd Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package client
import (
"context"
"testing"
. "github.com/containerd/containerd"
"github.com/containerd/containerd/runtime/linux/runctypes"
)
func TestWithNoNewKeyringAddsNoNewKeyringToOptions(t *testing.T) {
var taskInfo TaskInfo
var ctx context.Context
var client Client
err := WithNoNewKeyring(ctx, &client, &taskInfo)
if err != nil {
t.Fatal(err)
}
opts := taskInfo.Options.(*runctypes.CreateOptions)
if !opts.NoNewKeyring {
t.Fatal("NoNewKeyring set on WithNoNewKeyring")
}
}
func TestWithNoNewKeyringDoesNotOverwriteOtherOptions(t *testing.T) {
var taskInfo TaskInfo
var ctx context.Context
var client Client
taskInfo.Options = &runctypes.CreateOptions{NoPivotRoot: true}
err := WithNoNewKeyring(ctx, &client, &taskInfo)
if err != nil {
t.Fatal(err)
}
opts := taskInfo.Options.(*runctypes.CreateOptions)
if !opts.NoPivotRoot {
t.Fatal("WithNoNewKeyring overwrote other options")
}
}