Containerd client integration
This commit: 1) Replaces the usage of containerd GRPC APIs with the containerd client for all operations related to containerd. 2) Updated containerd to v1.0alpha4+ 3) Updated runc to v1.0.0 Signed-off-by: Abhinandan Prativadi <abhi@docker.com>
This commit is contained in:
@@ -19,6 +19,8 @@ package container
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-containerd/pkg/store"
|
||||
)
|
||||
|
||||
@@ -29,20 +31,35 @@ type Container struct {
|
||||
Metadata
|
||||
// Status stores the status of the container.
|
||||
Status StatusStorage
|
||||
// TODO(random-liu): Add containerd container client.
|
||||
// TODO(random-liu): Add stop channel to get rid of stop poll waiting.
|
||||
// Containerd container
|
||||
Container containerd.Container
|
||||
}
|
||||
|
||||
// Opts sets specific information to newly created Container.
|
||||
type Opts func(*Container)
|
||||
|
||||
// WithContainer adds the containerd Container to the internal data store.
|
||||
func WithContainer(cntr containerd.Container) Opts {
|
||||
return func(c *Container) {
|
||||
c.Container = cntr
|
||||
}
|
||||
}
|
||||
|
||||
// NewContainer creates an internally used container type.
|
||||
func NewContainer(metadata Metadata, status Status) (Container, error) {
|
||||
func NewContainer(metadata Metadata, status Status, opts ...Opts) (Container, error) {
|
||||
s, err := StoreStatus(metadata.ID, status)
|
||||
if err != nil {
|
||||
return Container{}, err
|
||||
}
|
||||
return Container{
|
||||
c := Container{
|
||||
Metadata: metadata,
|
||||
Status: s,
|
||||
}, nil
|
||||
}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&c)
|
||||
}
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Delete deletes checkpoint for the container.
|
||||
|
||||
@@ -19,6 +19,7 @@ package image
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-containerd/pkg/store"
|
||||
@@ -39,7 +40,8 @@ type Image struct {
|
||||
Size int64
|
||||
// Config is the oci image config of the image.
|
||||
Config *imagespec.ImageConfig
|
||||
// TODO(random-liu): Add containerd image client.
|
||||
// Containerd image reference
|
||||
Image containerd.Image
|
||||
}
|
||||
|
||||
// Store stores all images.
|
||||
|
||||
@@ -19,6 +19,8 @@ package sandbox
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-containerd/pkg/store"
|
||||
)
|
||||
|
||||
@@ -27,7 +29,8 @@ import (
|
||||
type Sandbox struct {
|
||||
// Metadata is the metadata of the sandbox, it is immutable after created.
|
||||
Metadata
|
||||
// TODO(random-liu): Add containerd container client.
|
||||
// Containerd sandbox container
|
||||
Container containerd.Container
|
||||
// TODO(random-liu): Add cni network namespace client.
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ func TestSandboxStore(t *testing.T) {
|
||||
assert := assertlib.New(t)
|
||||
sandboxes := map[string]Sandbox{}
|
||||
for _, id := range ids {
|
||||
sandboxes[id] = Sandbox{metadatas[id]}
|
||||
sandboxes[id] = Sandbox{Metadata: metadatas[id]}
|
||||
}
|
||||
|
||||
s := NewStore()
|
||||
|
||||
Reference in New Issue
Block a user