Skip to content

Commit

Permalink
Remove v1 runctypes
Browse files Browse the repository at this point in the history
Signed-off-by: Maksym Pavlenko <[email protected]>
  • Loading branch information
mxpv committed Mar 15, 2023
1 parent c50a3ef commit 07c2ae1
Show file tree
Hide file tree
Showing 31 changed files with 105 additions and 2,177 deletions.
8 changes: 0 additions & 8 deletions Protobuild.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ prefixes = [
]
generators = ["go", "go-grpc"]

# Lock down runc config
[[descriptors]]
prefix = "github.com/containerd/containerd/runtime/linux/runctypes"
target = "runtime/linux/runctypes/next.pb.txt"
ignore_files = [
"google/protobuf/descriptor.proto",
]

[[descriptors]]
prefix = "github.com/containerd/containerd/runtime/v2/runc/options"
target = "runtime/v2/runc/options/next.pb.txt"
Expand Down
17 changes: 0 additions & 17 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -818,23 +818,6 @@ func (c *Client) getSnapshotter(ctx context.Context, name string) (snapshots.Sna
return s, nil
}

// CheckRuntime returns true if the current runtime matches the expected
// runtime. Providing various parts of the runtime schema will match those
// parts of the expected runtime
func CheckRuntime(current, expected string) bool {
cp := strings.Split(current, ".")
l := len(cp)
for i, p := range strings.Split(expected, ".") {
if i > l {
return false
}
if p != cp[i] {
return false
}
}
return true
}

// GetSnapshotterSupportedPlatforms returns a platform matchers which represents the
// supported platforms for the given snapshotters
func (c *Client) GetSnapshotterSupportedPlatforms(ctx context.Context, snapshotterName string) (platforms.MatchComparer, error) {
Expand Down
45 changes: 13 additions & 32 deletions cmd/ctr/commands/tasks/checkpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import (

"github.com/containerd/containerd"
"github.com/containerd/containerd/cmd/ctr/commands"
"github.com/containerd/containerd/plugin"
"github.com/containerd/containerd/runtime/linux/runctypes"
"github.com/containerd/containerd/runtime/v2/runc/options"
"github.com/urfave/cli"
)
Expand Down Expand Up @@ -86,38 +84,21 @@ func withCheckpointOpts(rt string, context *cli.Context) containerd.CheckpointTa
imagePath := context.String("image-path")
workPath := context.String("work-path")

switch rt {
case plugin.RuntimeRuncV1, plugin.RuntimeRuncV2:
if r.Options == nil {
r.Options = &options.CheckpointOptions{}
}
opts, _ := r.Options.(*options.CheckpointOptions)

if context.Bool("exit") {
opts.Exit = true
}
if imagePath != "" {
opts.ImagePath = imagePath
}
if workPath != "" {
opts.WorkPath = workPath
}
case plugin.RuntimeLinuxV1:
if r.Options == nil {
r.Options = &runctypes.CheckpointOptions{}
}
opts, _ := r.Options.(*runctypes.CheckpointOptions)
if r.Options == nil {
r.Options = &options.CheckpointOptions{}
}
opts, _ := r.Options.(*options.CheckpointOptions)

if context.Bool("exit") {
opts.Exit = true
}
if imagePath != "" {
opts.ImagePath = imagePath
}
if workPath != "" {
opts.WorkPath = workPath
}
if context.Bool("exit") {
opts.Exit = true
}
if imagePath != "" {
opts.ImagePath = imagePath
}
if workPath != "" {
opts.WorkPath = workPath
}

return nil
}
}
16 changes: 0 additions & 16 deletions integration/client/container_checkpoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
62 changes: 4 additions & 58 deletions integration/client/container_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand All @@ -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)
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 0 additions & 5 deletions integration/client/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion integration/client/daemon_config_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
64 changes: 0 additions & 64 deletions integration/client/task_opts_unix_test.go

This file was deleted.

Loading

0 comments on commit 07c2ae1

Please sign in to comment.