update containerd for refactor
fix #423 Signed-off-by: yanxuean <yan.xuean@zte.com.cn>
This commit is contained in:
@@ -27,7 +27,7 @@ import (
|
||||
"github.com/containerd/containerd/containers"
|
||||
"github.com/containerd/containerd/contrib/apparmor"
|
||||
"github.com/containerd/containerd/contrib/seccomp"
|
||||
"github.com/containerd/containerd/linux/runcopts"
|
||||
"github.com/containerd/containerd/linux/runctypes"
|
||||
"github.com/containerd/containerd/mount"
|
||||
"github.com/containerd/containerd/namespaces"
|
||||
"github.com/containerd/typeurl"
|
||||
@@ -227,7 +227,7 @@ func (c *criContainerdService) CreateContainer(ctx context.Context, r *runtime.C
|
||||
containerd.WithSpec(spec, specOpts...),
|
||||
containerd.WithRuntime(
|
||||
c.config.ContainerdConfig.Runtime,
|
||||
&runcopts.RuncOptions{
|
||||
&runctypes.RuncOptions{
|
||||
Runtime: c.config.ContainerdConfig.RuntimeEngine,
|
||||
RuntimeRoot: c.config.ContainerdConfig.RuntimeRoot,
|
||||
SystemdCgroup: c.config.SystemdCgroup}), // TODO (mikebrow): add CriuPath when we add support for pause
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/golang/glog"
|
||||
"github.com/opencontainers/runtime-tools/generate"
|
||||
@@ -118,7 +119,7 @@ func (c *criContainerdService) execInContainer(ctx context.Context, id string, o
|
||||
rootDir := getContainerRootDir(c.config.RootDir, id)
|
||||
var execIO *cio.ExecIO
|
||||
process, err := task.Exec(ctx, execID, pspec,
|
||||
func(id string) (containerd.IO, error) {
|
||||
func(id string) (containerdio.IO, error) {
|
||||
var err error
|
||||
execIO, err = cio.NewExecIO(id, rootDir, opts.tty, opts.stdin != nil)
|
||||
return execIO, err
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/golang/glog"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||
@@ -103,7 +104,7 @@ func (c *criContainerdService) startContainer(ctx context.Context,
|
||||
return fmt.Errorf("sandbox container %q is not running", sandboxID)
|
||||
}
|
||||
|
||||
ioCreation := func(id string) (_ containerd.IO, err error) {
|
||||
ioCreation := func(id string) (_ containerdio.IO, err error) {
|
||||
stdoutWC, stderrWC, err := createContainerLoggers(meta.LogPath, config.GetTty())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create container loggers: %v", err)
|
||||
|
||||
@@ -17,8 +17,9 @@ limitations under the License.
|
||||
package server
|
||||
|
||||
import (
|
||||
"github.com/containerd/containerd"
|
||||
eventtypes "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/api/services/events/v1"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/golang/glog"
|
||||
@@ -88,8 +89,8 @@ func (em *eventMonitor) handleEvent(evt *events.Envelope) {
|
||||
// However, containerd could not retrieve container state in that case, so it's
|
||||
// fine to leave out that case for now.
|
||||
// TODO(random-liu): [P2] Handle containerd-shim exit.
|
||||
case *events.TaskExit:
|
||||
e := any.(*events.TaskExit)
|
||||
case *eventtypes.TaskExit:
|
||||
e := any.(*eventtypes.TaskExit)
|
||||
glog.V(2).Infof("TaskExit event %+v", e)
|
||||
cntr, err := c.containerStore.Get(e.ContainerID)
|
||||
if err != nil {
|
||||
@@ -105,7 +106,7 @@ func (em *eventMonitor) handleEvent(evt *events.Envelope) {
|
||||
}
|
||||
// Attach container IO so that `Delete` could cleanup the stream properly.
|
||||
task, err := cntr.Container.Task(context.Background(),
|
||||
func(*containerd.FIFOSet) (containerd.IO, error) {
|
||||
func(*containerdio.FIFOSet) (containerdio.IO, error) {
|
||||
return cntr.IO, nil
|
||||
},
|
||||
)
|
||||
@@ -141,8 +142,8 @@ func (em *eventMonitor) handleEvent(evt *events.Envelope) {
|
||||
// TODO(random-liu): [P0] Enqueue the event and retry.
|
||||
return
|
||||
}
|
||||
case *events.TaskOOM:
|
||||
e := any.(*events.TaskOOM)
|
||||
case *eventtypes.TaskOOM:
|
||||
e := any.(*eventtypes.TaskOOM)
|
||||
glog.V(2).Infof("TaskOOM event %+v", e)
|
||||
cntr, err := c.containerStore.Get(e.ContainerID)
|
||||
if err != nil {
|
||||
|
||||
@@ -23,7 +23,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/golang/glog"
|
||||
|
||||
cioutil "github.com/kubernetes-incubator/cri-containerd/pkg/ioutil"
|
||||
@@ -39,7 +39,7 @@ func streamKey(id, name string, stream StreamType) string {
|
||||
type ContainerIO struct {
|
||||
id string
|
||||
|
||||
fifos *containerd.FIFOSet
|
||||
fifos *cio.FIFOSet
|
||||
*stdioPipes
|
||||
|
||||
stdoutGroup *cioutil.WriterGroup
|
||||
@@ -48,7 +48,7 @@ type ContainerIO struct {
|
||||
closer *wgCloser
|
||||
}
|
||||
|
||||
var _ containerd.IO = &ContainerIO{}
|
||||
var _ cio.IO = &ContainerIO{}
|
||||
|
||||
// ContainerIOOpts sets specific information to newly created ContainerIO.
|
||||
type ContainerIOOpts func(*ContainerIO) error
|
||||
@@ -71,7 +71,7 @@ func WithOutput(name string, stdout, stderr io.WriteCloser) ContainerIOOpts {
|
||||
}
|
||||
|
||||
// WithFIFOs specifies existing fifos for the container io.
|
||||
func WithFIFOs(fifos *containerd.FIFOSet) ContainerIOOpts {
|
||||
func WithFIFOs(fifos *cio.FIFOSet) ContainerIOOpts {
|
||||
return func(c *ContainerIO) error {
|
||||
c.fifos = fifos
|
||||
return nil
|
||||
@@ -115,8 +115,8 @@ func NewContainerIO(id string, opts ...ContainerIOOpts) (_ *ContainerIO, err err
|
||||
}
|
||||
|
||||
// Config returns io config.
|
||||
func (c *ContainerIO) Config() containerd.IOConfig {
|
||||
return containerd.IOConfig{
|
||||
func (c *ContainerIO) Config() cio.Config {
|
||||
return cio.Config{
|
||||
Terminal: c.fifos.Terminal,
|
||||
Stdin: c.fifos.In,
|
||||
Stdout: c.fifos.Out,
|
||||
|
||||
@@ -21,7 +21,7 @@ import (
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/golang/glog"
|
||||
|
||||
cioutil "github.com/kubernetes-incubator/cri-containerd/pkg/ioutil"
|
||||
@@ -30,12 +30,12 @@ import (
|
||||
// ExecIO holds the exec io.
|
||||
type ExecIO struct {
|
||||
id string
|
||||
fifos *containerd.FIFOSet
|
||||
fifos *cio.FIFOSet
|
||||
*stdioPipes
|
||||
closer *wgCloser
|
||||
}
|
||||
|
||||
var _ containerd.IO = &ExecIO{}
|
||||
var _ cio.IO = &ExecIO{}
|
||||
|
||||
// NewExecIO creates exec io.
|
||||
func NewExecIO(id, root string, tty, stdin bool) (*ExecIO, error) {
|
||||
@@ -56,8 +56,8 @@ func NewExecIO(id, root string, tty, stdin bool) (*ExecIO, error) {
|
||||
}
|
||||
|
||||
// Config returns io config.
|
||||
func (e *ExecIO) Config() containerd.IOConfig {
|
||||
return containerd.IOConfig{
|
||||
func (e *ExecIO) Config() cio.Config {
|
||||
return cio.Config{
|
||||
Terminal: e.fifos.Terminal,
|
||||
Stdin: e.fifos.In,
|
||||
Stdout: e.fifos.Out,
|
||||
|
||||
@@ -24,7 +24,7 @@ import (
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/fifo"
|
||||
"golang.org/x/net/context"
|
||||
"k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime"
|
||||
@@ -75,7 +75,7 @@ func (g *wgCloser) Cancel() {
|
||||
}
|
||||
|
||||
// newFifos creates fifos directory for a container.
|
||||
func newFifos(root, id string, tty, stdin bool) (*containerd.FIFOSet, error) {
|
||||
func newFifos(root, id string, tty, stdin bool) (*cio.FIFOSet, error) {
|
||||
root = filepath.Join(root, "io")
|
||||
if err := os.MkdirAll(root, 0700); err != nil {
|
||||
return nil, err
|
||||
@@ -84,7 +84,7 @@ func newFifos(root, id string, tty, stdin bool) (*containerd.FIFOSet, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fifos := &containerd.FIFOSet{
|
||||
fifos := &cio.FIFOSet{
|
||||
Dir: dir,
|
||||
In: filepath.Join(dir, id+"-stdin"),
|
||||
Out: filepath.Join(dir, id+"-stdout"),
|
||||
@@ -104,7 +104,7 @@ type stdioPipes struct {
|
||||
}
|
||||
|
||||
// newStdioPipes creates actual fifos for stdio.
|
||||
func newStdioPipes(fifos *containerd.FIFOSet) (_ *stdioPipes, _ *wgCloser, err error) {
|
||||
func newStdioPipes(fifos *cio.FIFOSet) (_ *stdioPipes, _ *wgCloser, err error) {
|
||||
var (
|
||||
f io.ReadWriteCloser
|
||||
set []io.Closer
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/content"
|
||||
"github.com/containerd/containerd/errdefs"
|
||||
containerdimages "github.com/containerd/containerd/images"
|
||||
@@ -154,7 +155,7 @@ func loadContainer(ctx context.Context, cntr containerd.Container, containerDir
|
||||
|
||||
// Load up-to-date status from containerd.
|
||||
var containerIO *cio.ContainerIO
|
||||
t, err := cntr.Task(ctx, func(fifos *containerd.FIFOSet) (containerd.IO, error) {
|
||||
t, err := cntr.Task(ctx, func(fifos *containerdio.FIFOSet) (containerdio.IO, error) {
|
||||
stdoutWC, stderrWC, err := createContainerLoggers(meta.LogPath, meta.Config.GetTty())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -22,7 +22,8 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/linux/runcopts"
|
||||
containerdio "github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/linux/runctypes"
|
||||
"github.com/containerd/typeurl"
|
||||
"github.com/cri-o/ocicni/pkg/ocicni"
|
||||
"github.com/golang/glog"
|
||||
@@ -154,7 +155,7 @@ func (c *criContainerdService) RunPodSandbox(ctx context.Context, r *runtime.Run
|
||||
containerd.WithContainerExtension(sandboxMetadataExtension, &sandbox.Metadata),
|
||||
containerd.WithRuntime(
|
||||
c.config.ContainerdConfig.Runtime,
|
||||
&runcopts.RuncOptions{
|
||||
&runctypes.RuncOptions{
|
||||
Runtime: c.config.ContainerdConfig.RuntimeEngine,
|
||||
RuntimeRoot: c.config.ContainerdConfig.RuntimeRoot,
|
||||
SystemdCgroup: c.config.SystemdCgroup})} // TODO (mikebrow): add CriuPath when we add support for pause
|
||||
@@ -204,7 +205,7 @@ func (c *criContainerdService) RunPodSandbox(ctx context.Context, r *runtime.Run
|
||||
glog.V(5).Infof("Create sandbox container (id=%q, name=%q).",
|
||||
id, name)
|
||||
// We don't need stdio for sandbox container.
|
||||
task, err := container.NewTask(ctx, containerd.NullIO)
|
||||
task, err := container.NewTask(ctx, containerdio.NullIO)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create task for sandbox %q: %v", id, err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user