Skip to content

Commit

Permalink
Merge pull request #3526 from akhilerm/test-containerd-api-module
Browse files Browse the repository at this point in the history
use containerd/containerd/api module
  • Loading branch information
iwankgb authored Jul 11, 2024
2 parents 7c7032b + c73fbd8 commit c9375fe
Show file tree
Hide file tree
Showing 86 changed files with 60 additions and 67,523 deletions.
44 changes: 0 additions & 44 deletions build/update-containerd-api.sh

This file was deleted.

7 changes: 5 additions & 2 deletions cmd/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ require (
github.com/checkpoint-restore/go-criu/v5 v5.3.0 // indirect
github.com/cilium/ebpf v0.7.0 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/containerd/ttrpc v1.2.4 // indirect
github.com/containerd/containerd/api v1.7.19 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/ttrpc v1.2.5 // indirect
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down Expand Up @@ -97,7 +100,7 @@ require (
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/mrunalp/fileutils v0.5.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runc v1.1.13 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opencontainers/selinux v1.10.0 // indirect
Expand Down
16 changes: 10 additions & 6 deletions cmd/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,16 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/containerd/containerd/api v1.7.19 h1:VWbJL+8Ap4Ju2mx9c9qS1uFSB1OVYr5JJrW2yT5vFoA=
github.com/containerd/containerd/api v1.7.19/go.mod h1:fwGavl3LNwAV5ilJ0sbrABL44AQxmNjDRcwheXDb6Ig=
github.com/containerd/errdefs v0.1.0 h1:m0wCRBiu1WJT/Fr+iOoQHMQS/eP5myQ8lCv4Dz5ZURM=
github.com/containerd/errdefs v0.1.0/go.mod h1:YgWiiHtLmSeBrvpw+UfPijzbLaB77mEG1WwJTDETIV0=
github.com/containerd/log v0.1.0 h1:TCJt7ioM2cr/tfR8GPbGf9/VRAX8D2B4PjzCpfX540I=
github.com/containerd/log v0.1.0/go.mod h1:VRRf09a7mHDIRezVKTRCrOq78v577GXq3bSa3EhrzVo=
github.com/containerd/ttrpc v1.2.4 h1:eQCQK4h9dxDmpOb9QOOMh2NHTfzroH1IkmHiKZi05Oo=
github.com/containerd/ttrpc v1.2.4/go.mod h1:ojvb8SJBSch0XkqNO0L0YX/5NxR3UnVk2LzFKBK0upc=
github.com/containerd/typeurl v1.0.2 h1:Chlt8zIieDbzQFzXzAeBEF92KhExuE4p9p92/QmY7aY=
github.com/containerd/typeurl v1.0.2/go.mod h1:9trJWW2sRlGub4wZJRTW83VtbOLS6hwcDZXTn6oPz9s=
github.com/containerd/ttrpc v1.2.5 h1:IFckT1EFQoFBMG4c3sMdT8EP3/aKfumK1msY+Ze4oLU=
github.com/containerd/ttrpc v1.2.5/go.mod h1:YCXHsb32f+Sq5/72xHubdiJRQY9inL4a4ZQrAbN1q9o=
github.com/containerd/typeurl/v2 v2.2.0 h1:6NBDbQzr7I5LHgp34xAXYF5DOTQDn05X58lsPEmzLso=
github.com/containerd/typeurl/v2 v2.2.0/go.mod h1:8XOOxnyatxSWuG8OfsZXVnAF4iZfedjS/8UHSPJnX4g=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534 h1:rtAn27wIbmOGUs7RIbVgPEjb31ehTVniDwPGXyMxm5U=
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
Expand Down Expand Up @@ -337,8 +341,8 @@ github.com/onsi/gomega v1.24.1 h1:KORJXNNTzJXzu4ScJWssJfJMnJ+2QJqhoQSRwNlze9E=
github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM=
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
github.com/opencontainers/image-spec v1.0.2 h1:9yCKha/T5XdGtO0q9Q9a6T5NUCsTn/DrBg0D7ufOcFM=
github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug=
github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM=
github.com/opencontainers/runc v1.1.13 h1:98S2srgG9vw0zWcDpFMn5TRrh8kLxa/5OFUstuUhmRs=
github.com/opencontainers/runc v1.1.13/go.mod h1:R016aXacfp/gwQBYw2FDGa9m+n6atbLWrYY8hNMT/sA=
github.com/opencontainers/runtime-spec v1.2.0 h1:z97+pHb3uELt/yiAWD691HNHQIF07bE7dzrbT927iTk=
Expand Down
19 changes: 10 additions & 9 deletions container/containerd/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ import (
"sync"
"time"

ptypes "github.com/gogo/protobuf/types"
containersapi "github.com/containerd/containerd/api/services/containers/v1"
tasksapi "github.com/containerd/containerd/api/services/tasks/v1"
versionapi "github.com/containerd/containerd/api/services/version/v1"
tasktypes "github.com/containerd/containerd/api/types/task"
"github.com/containerd/errdefs"
"google.golang.org/grpc"
"google.golang.org/grpc/backoff"
"google.golang.org/grpc/credentials/insecure"
emptypb "google.golang.org/protobuf/types/known/emptypb"

"github.com/google/cadvisor/container/containerd/containers"
"github.com/google/cadvisor/container/containerd/errdefs"
"github.com/google/cadvisor/container/containerd/pkg/dialer"
containersapi "github.com/google/cadvisor/third_party/containerd/api/services/containers/v1"
tasksapi "github.com/google/cadvisor/third_party/containerd/api/services/tasks/v1"
versionapi "github.com/google/cadvisor/third_party/containerd/api/services/version/v1"
tasktypes "github.com/google/cadvisor/third_party/containerd/api/types/task"
)

type client struct {
Expand Down Expand Up @@ -126,22 +126,23 @@ func (c *client) TaskPid(ctx context.Context, id string) (uint32, error) {
if err != nil {
return 0, errdefs.FromGRPC(err)
}
if response.Process.Status == tasktypes.StatusUnknown {
if response.Process.Status == tasktypes.Status_UNKNOWN {
return 0, ErrTaskIsInUnknownState
}
return response.Process.Pid, nil
}

func (c *client) Version(ctx context.Context) (string, error) {
response, err := c.versionService.Version(ctx, &ptypes.Empty{})
response, err := c.versionService.Version(ctx, &emptypb.Empty{})
if err != nil {
return "", errdefs.FromGRPC(err)
}
return response.Version, nil
}

func containerFromProto(containerpb containersapi.Container) *containers.Container {
func containerFromProto(containerpb *containersapi.Container) *containers.Container {
var runtime containers.RuntimeInfo
// TODO: is nil check required for containerpb
if containerpb.Runtime != nil {
runtime = containers.RuntimeInfo{
Name: containerpb.Runtime.Name,
Expand Down
8 changes: 4 additions & 4 deletions container/containerd/containers/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
"context"
"time"

"github.com/gogo/protobuf/types"
"google.golang.org/protobuf/types/known/anypb"
)

// Container represents the set of data pinned by a container. Unless otherwise
Expand Down Expand Up @@ -66,7 +66,7 @@ type Container struct {
// container.
//
// This field is required but mutable.
Spec *types.Any
Spec *anypb.Any

// SnapshotKey specifies the snapshot key to use for the container's root
// filesystem. When starting a task from this container, a caller should
Expand All @@ -88,13 +88,13 @@ type Container struct {
UpdatedAt time.Time

// Extensions stores client-specified metadata
Extensions map[string]types.Any
Extensions map[string]*anypb.Any
}

// RuntimeInfo holds runtime specific information
type RuntimeInfo struct {
Name string
Options *types.Any
Options *anypb.Any
}

// Store interacts with the underlying container storage
Expand Down
106 changes: 0 additions & 106 deletions container/containerd/errdefs/errors.go

This file was deleted.

Loading

0 comments on commit c9375fe

Please sign in to comment.