mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-09 01:14:20 +01:00
runtime: bump containerd for gogo deprecation
This update includes necessary changes due to the version bump of containerd and its dependencies. It's part of a broader initiative to phase out gogo protobuf, which has been deprecated, and to align with the current supported libraries. Fixes #7420. Signed-off-by: Beraldo Leal <bleal@redhat.com>
This commit is contained in:
@@ -9,9 +9,9 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
@@ -60,7 +60,7 @@ func newContainer(s *service, r *taskAPI.CreateTaskRequest, containerType vc.Con
|
||||
terminal: r.Terminal,
|
||||
cType: containerType,
|
||||
execs: make(map[string]*exec),
|
||||
status: task.StatusCreated,
|
||||
status: task.Status_CREATED,
|
||||
exitIOch: make(chan struct{}),
|
||||
exitCh: make(chan uint32, 1),
|
||||
stdinCloser: make(chan struct{}),
|
||||
|
||||
@@ -8,7 +8,7 @@ package containerdshim
|
||||
import (
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ import (
|
||||
"syscall"
|
||||
|
||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
containerd_types "github.com/containerd/containerd/api/types"
|
||||
"github.com/containerd/containerd/mount"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/utils"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations"
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
"path"
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
crioption "github.com/containerd/cri-containerd/pkg/api/runtimeoptions/v1"
|
||||
"github.com/containerd/typeurl"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -395,7 +395,7 @@ func TestCreateLoadRuntimeConfig(t *testing.T) {
|
||||
fakeConfig := "foobar"
|
||||
anno[vcAnnotations.SandboxConfigPathKey] = fakeConfig
|
||||
option := &crioption.Options{ConfigPath: fakeConfig}
|
||||
r.Options, err = typeurl.MarshalAny(option)
|
||||
r.Options, err = protobuf.MarshalAnyToProto(option)
|
||||
assert.NoError(err)
|
||||
err = os.Setenv("KATA_CONF_FILE", fakeConfig)
|
||||
assert.NoError(err)
|
||||
@@ -413,12 +413,12 @@ func TestCreateLoadRuntimeConfig(t *testing.T) {
|
||||
|
||||
// 2. shimv2 create task option
|
||||
option.ConfigPath = config
|
||||
r.Options, err = typeurl.MarshalAny(option)
|
||||
r.Options, err = protobuf.MarshalAnyToProto(option)
|
||||
assert.NoError(err)
|
||||
_, err = loadRuntimeConfig(s, r, anno)
|
||||
assert.NoError(err)
|
||||
option.ConfigPath = ""
|
||||
r.Options, err = typeurl.MarshalAny(option)
|
||||
r.Options, err = protobuf.MarshalAnyToProto(option)
|
||||
assert.NoError(err)
|
||||
|
||||
// 3. environment
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
|
||||
func deleteContainer(ctx context.Context, s *service, c *container) error {
|
||||
if !c.cType.IsSandbox() {
|
||||
if c.status != task.StatusStopped {
|
||||
if c.status != task.Status_STOPPED {
|
||||
if _, err := s.sandbox.StopContainer(ctx, c.id, false); err != nil && !isNotFound(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ package containerdshim
|
||||
import (
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
ktu "github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils"
|
||||
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
)
|
||||
|
||||
type exec struct {
|
||||
@@ -126,7 +126,7 @@ func newExec(c *container, stdin, stdout, stderr string, terminal bool, jspec *a
|
||||
exitIOch: make(chan struct{}),
|
||||
stdinCloser: make(chan struct{}),
|
||||
exitCh: make(chan uint32, 1),
|
||||
status: task.StatusCreated,
|
||||
status: task.Status_CREATED,
|
||||
}
|
||||
|
||||
return exec, nil
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/vcmock"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
@@ -10,8 +10,7 @@ import (
|
||||
|
||||
cgroupsv1 "github.com/containerd/cgroups/stats/v1"
|
||||
cgroupsv2 "github.com/containerd/cgroups/v2/stats"
|
||||
"github.com/containerd/typeurl"
|
||||
|
||||
"github.com/containerd/containerd/protobuf"
|
||||
resCtrl "github.com/kata-containers/kata-containers/src/runtime/pkg/resourcecontrol"
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
anypb "google.golang.org/protobuf/types/known/anypb"
|
||||
@@ -36,7 +35,7 @@ func marshalMetrics(ctx context.Context, s *service, containerID string) (*anypb
|
||||
metrics = statsToMetricsV2(&stats)
|
||||
}
|
||||
|
||||
data, err := typeurl.MarshalAny(metrics)
|
||||
data, err := protobuf.MarshalAnyToProto(metrics)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/vcmock"
|
||||
|
||||
@@ -17,20 +17,13 @@ import (
|
||||
"time"
|
||||
|
||||
eventstypes "github.com/containerd/containerd/api/events"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/containerd/containerd/api/types/task"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
cdruntime "github.com/containerd/containerd/runtime"
|
||||
cdshim "github.com/containerd/containerd/runtime/v2/shim"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
otelTrace "go.opentelemetry.io/otel/trace"
|
||||
"golang.org/x/sys/unix"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
|
||||
"github.com/containerd/typeurl/v2"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/katautils/katatrace"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/pkg/oci"
|
||||
@@ -38,6 +31,13 @@ import (
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/compatoci"
|
||||
"github.com/kata-containers/kata-containers/src/runtime/virtcontainers/types"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
otelTrace "go.opentelemetry.io/otel/trace"
|
||||
"golang.org/x/sys/unix"
|
||||
emptypb "google.golang.org/protobuf/types/known/emptypb"
|
||||
"google.golang.org/protobuf/types/known/timestamppb"
|
||||
)
|
||||
|
||||
// shimTracingTags defines tags for the trace span
|
||||
@@ -372,7 +372,7 @@ func (s *service) Cleanup(ctx context.Context) (_ *taskAPI.DeleteResponse, err e
|
||||
}
|
||||
|
||||
return &taskAPI.DeleteResponse{
|
||||
ExitedAt: time.Now(),
|
||||
ExitedAt: timestamppb.New(time.Now()),
|
||||
ExitStatus: 128 + uint32(unix.SIGKILL),
|
||||
}, nil
|
||||
}
|
||||
@@ -412,7 +412,7 @@ func (s *service) Create(ctx context.Context, r *taskAPI.CreateTaskRequest) (_ *
|
||||
return nil, res.err
|
||||
}
|
||||
container := res.container
|
||||
container.status = task.StatusCreated
|
||||
container.status = task.Status_CREATED
|
||||
|
||||
s.containers[r.ID] = container
|
||||
|
||||
@@ -519,12 +519,12 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *task
|
||||
ContainerID: c.id,
|
||||
Pid: s.hpid,
|
||||
ExitStatus: c.exit,
|
||||
ExitedAt: c.exitTime,
|
||||
ExitedAt: timestamppb.New(c.exitTime),
|
||||
})
|
||||
|
||||
return &taskAPI.DeleteResponse{
|
||||
ExitStatus: c.exit,
|
||||
ExitedAt: c.exitTime,
|
||||
ExitedAt: timestamppb.New(c.exitTime),
|
||||
Pid: s.hpid,
|
||||
}, nil
|
||||
}
|
||||
@@ -538,7 +538,7 @@ func (s *service) Delete(ctx context.Context, r *taskAPI.DeleteRequest) (_ *task
|
||||
|
||||
return &taskAPI.DeleteResponse{
|
||||
ExitStatus: uint32(execs.exitCode),
|
||||
ExitedAt: execs.exitTime,
|
||||
ExitedAt: timestamppb.New(execs.exitTime),
|
||||
Pid: s.hpid,
|
||||
}, nil
|
||||
}
|
||||
@@ -656,7 +656,7 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (_ *taskAP
|
||||
Stderr: c.stderr,
|
||||
Terminal: c.terminal,
|
||||
ExitStatus: c.exit,
|
||||
ExitedAt: c.exitTime,
|
||||
ExitedAt: timestamppb.New(c.exitTime),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -676,7 +676,7 @@ func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (_ *taskAP
|
||||
Stderr: execs.tty.stderr,
|
||||
Terminal: execs.tty.terminal,
|
||||
ExitStatus: uint32(execs.exitCode),
|
||||
ExitedAt: execs.exitTime,
|
||||
ExitedAt: timestamppb.New(execs.exitTime),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -701,11 +701,11 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *emptyp
|
||||
return nil, err
|
||||
}
|
||||
|
||||
c.status = task.StatusPausing
|
||||
c.status = task.Status_PAUSING
|
||||
|
||||
err = s.sandbox.PauseContainer(spanCtx, r.ID)
|
||||
if err == nil {
|
||||
c.status = task.StatusPaused
|
||||
c.status = task.Status_PAUSED
|
||||
s.send(&eventstypes.TaskPaused{
|
||||
ContainerID: c.id,
|
||||
})
|
||||
@@ -713,7 +713,7 @@ func (s *service) Pause(ctx context.Context, r *taskAPI.PauseRequest) (_ *emptyp
|
||||
}
|
||||
|
||||
if status, err := s.getContainerStatus(c.id); err != nil {
|
||||
c.status = task.StatusUnknown
|
||||
c.status = task.Status_UNKNOWN
|
||||
} else {
|
||||
c.status = status
|
||||
}
|
||||
@@ -744,7 +744,7 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *empt
|
||||
|
||||
err = s.sandbox.ResumeContainer(spanCtx, c.id)
|
||||
if err == nil {
|
||||
c.status = task.StatusRunning
|
||||
c.status = task.Status_RUNNING
|
||||
s.send(&eventstypes.TaskResumed{
|
||||
ContainerID: c.id,
|
||||
})
|
||||
@@ -752,7 +752,7 @@ func (s *service) Resume(ctx context.Context, r *taskAPI.ResumeRequest) (_ *empt
|
||||
}
|
||||
|
||||
if status, err := s.getContainerStatus(c.id); err != nil {
|
||||
c.status = task.StatusUnknown
|
||||
c.status = task.Status_UNKNOWN
|
||||
} else {
|
||||
c.status = status
|
||||
}
|
||||
@@ -811,7 +811,7 @@ func (s *service) Kill(ctx context.Context, r *taskAPI.KillRequest) (_ *emptypb.
|
||||
// send a SIGKILL signal first to try to stop the container, thus
|
||||
// once the container has terminated, here should ignore this signal
|
||||
// and return directly.
|
||||
if (signum == syscall.SIGKILL || signum == syscall.SIGTERM) && processStatus == task.StatusStopped {
|
||||
if (signum == syscall.SIGKILL || signum == syscall.SIGTERM) && processStatus == task.Status_STOPPED {
|
||||
shimLog.WithFields(logrus.Fields{
|
||||
"sandbox": s.sandbox.ID(),
|
||||
"container": c.id,
|
||||
@@ -1086,7 +1086,7 @@ func (s *service) Wait(ctx context.Context, r *taskAPI.WaitRequest) (_ *taskAPI.
|
||||
|
||||
return &taskAPI.WaitResponse{
|
||||
ExitStatus: ret,
|
||||
ExitedAt: c.exitTime,
|
||||
ExitedAt: timestamppb.New(c.exitTime),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -1110,7 +1110,7 @@ func (s *service) checkProcesses(e exit) {
|
||||
ID: id,
|
||||
Pid: e.pid,
|
||||
ExitStatus: uint32(e.status),
|
||||
ExitedAt: e.timestamp,
|
||||
ExitedAt: timestamppb.New(e.timestamp),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1127,19 +1127,19 @@ func (s *service) getContainer(id string) (*container, error) {
|
||||
func (s *service) getContainerStatus(containerID string) (task.Status, error) {
|
||||
cStatus, err := s.sandbox.StatusContainer(containerID)
|
||||
if err != nil {
|
||||
return task.StatusUnknown, err
|
||||
return task.Status_UNKNOWN, err
|
||||
}
|
||||
|
||||
var status task.Status
|
||||
switch cStatus.State.State {
|
||||
case types.StateReady:
|
||||
status = task.StatusCreated
|
||||
status = task.Status_CREATED
|
||||
case types.StateRunning:
|
||||
status = task.StatusRunning
|
||||
status = task.Status_RUNNING
|
||||
case types.StatePaused:
|
||||
status = task.StatusPaused
|
||||
status = task.Status_PAUSED
|
||||
case types.StateStopped:
|
||||
status = task.StatusStopped
|
||||
status = task.Status_STOPPED
|
||||
}
|
||||
|
||||
return status, nil
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
ktu "github.com/kata-containers/kata-containers/src/runtime/pkg/katatestutils"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
@@ -66,7 +66,7 @@ func startContainer(ctx context.Context, s *service, c *container) (retErr error
|
||||
shimLog.WithError(err).Warn("Failed to run post-start hooks")
|
||||
}
|
||||
|
||||
c.status = task.StatusRunning
|
||||
c.status = task.Status_RUNNING
|
||||
|
||||
stdin, stdout, stderr, err := s.sandbox.IOStream(c.id, c.id)
|
||||
if err != nil {
|
||||
@@ -127,7 +127,7 @@ func startExec(ctx context.Context, s *service, containerID, execID string) (e *
|
||||
}
|
||||
execs.id = proc.Token
|
||||
|
||||
execs.status = task.StatusRunning
|
||||
execs.status = task.Status_RUNNING
|
||||
if execs.tty.height != 0 && execs.tty.width != 0 {
|
||||
err = s.sandbox.WinsizeProcess(ctx, c.id, execs.id, execs.tty.height, execs.tty.width)
|
||||
if err != nil {
|
||||
|
||||
@@ -10,8 +10,8 @@ import (
|
||||
"context"
|
||||
"testing"
|
||||
|
||||
taskAPI "github.com/containerd/containerd/api/runtime/task/v2"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
taskAPI "github.com/containerd/containerd/runtime/v2/task"
|
||||
|
||||
vc "github.com/kata-containers/kata-containers/src/runtime/virtcontainers"
|
||||
vcAnnotations "github.com/kata-containers/kata-containers/src/runtime/virtcontainers/pkg/annotations"
|
||||
|
||||
@@ -87,14 +87,14 @@ func wait(ctx context.Context, s *service, c *container, execID string) (int32,
|
||||
shimLog.WithError(err).WithField("container", c.id).Warn("stop container failed")
|
||||
}
|
||||
}
|
||||
c.status = task.StatusStopped
|
||||
c.status = task.Status_STOPPED
|
||||
c.exit = uint32(ret)
|
||||
c.exitTime = timeStamp
|
||||
|
||||
c.exitCh <- uint32(ret)
|
||||
shimLog.WithField("container", c.id).Debug("The container status is StatusStopped")
|
||||
} else {
|
||||
execs.status = task.StatusStopped
|
||||
execs.status = task.Status_STOPPED
|
||||
execs.exitCode = ret
|
||||
execs.exitTime = timeStamp
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
|
||||
pb "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
|
||||
pb "k8s.io/cri-api/pkg/apis/runtime/v1"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user