Merge pull request #40146 from thaJeztah/move_hcsshim
libcontainerd: move hcsshim import to windows-only file
This commit is contained in:
commit
36cf709abd
3 changed files with 38 additions and 19 deletions
|
@ -13,7 +13,6 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
|
||||
"github.com/containerd/containerd"
|
||||
apievents "github.com/containerd/containerd/api/events"
|
||||
"github.com/containerd/containerd/api/types"
|
||||
|
@ -28,7 +27,6 @@ import (
|
|||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/libcontainerd/queue"
|
||||
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
|
||||
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
v1 "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
|
@ -192,6 +190,27 @@ func (c *client) Start(ctx context.Context, id, checkpointDir string, withStdin
|
|||
}
|
||||
bundle := labels[DockerContainerBundlePath]
|
||||
uid, gid := getSpecUser(spec)
|
||||
|
||||
taskOpts := []containerd.NewTaskOpts{
|
||||
func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
||||
info.Checkpoint = cp
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
if runtime.GOOS != "windows" {
|
||||
taskOpts = append(taskOpts, func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
||||
info.Options = &runctypes.CreateOptions{
|
||||
IoUid: uint32(uid),
|
||||
IoGid: uint32(gid),
|
||||
NoPivotRoot: os.Getenv("DOCKER_RAMDISK") != "",
|
||||
}
|
||||
return nil
|
||||
})
|
||||
} else {
|
||||
taskOpts = append(taskOpts, withLogLevel(c.logger.Level))
|
||||
}
|
||||
|
||||
t, err = ctr.NewTask(ctx,
|
||||
func(id string) (cio.IO, error) {
|
||||
fifos := newFIFOSet(bundle, libcontainerdtypes.InitProcessName, withStdin, spec.Process.Terminal)
|
||||
|
@ -199,22 +218,8 @@ func (c *client) Start(ctx context.Context, id, checkpointDir string, withStdin
|
|||
rio, err = c.createIO(fifos, id, libcontainerdtypes.InitProcessName, stdinCloseSync, attachStdio)
|
||||
return rio, err
|
||||
},
|
||||
func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
||||
info.Checkpoint = cp
|
||||
if runtime.GOOS != "windows" {
|
||||
info.Options = &runctypes.CreateOptions{
|
||||
IoUid: uint32(uid),
|
||||
IoGid: uint32(gid),
|
||||
NoPivotRoot: os.Getenv("DOCKER_RAMDISK") != "",
|
||||
}
|
||||
} else {
|
||||
// Make sure we set the runhcs options to debug if we are at debug level.
|
||||
if c.logger.Level == logrus.DebugLevel {
|
||||
info.Options = &options.Options{Debug: true}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
taskOpts...,
|
||||
)
|
||||
if err != nil {
|
||||
close(stdinCloseSync)
|
||||
if rio != nil {
|
||||
|
|
|
@ -94,6 +94,10 @@ func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOp
|
|||
}
|
||||
}
|
||||
|
||||
func withLogLevel(_ logrus.Level) containerd.NewTaskOpts {
|
||||
panic("Not implemented")
|
||||
}
|
||||
|
||||
func newFIFOSet(bundleDir, processID string, withStdin, withTerminal bool) *cio.FIFOSet {
|
||||
config := cio.Config{
|
||||
Terminal: withTerminal,
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
"github.com/containerd/containerd"
|
||||
"github.com/containerd/containerd/cio"
|
||||
"github.com/containerd/containerd/containers"
|
||||
|
||||
libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
const runtimeName = "io.containerd.runhcs.v1"
|
||||
|
@ -49,6 +49,16 @@ func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOp
|
|||
}
|
||||
}
|
||||
|
||||
func withLogLevel(level logrus.Level) containerd.NewTaskOpts {
|
||||
// Make sure we set the runhcs options to debug if we are at debug level.
|
||||
return func(_ context.Context, _ *containerd.Client, info *containerd.TaskInfo) error {
|
||||
if level == logrus.DebugLevel {
|
||||
info.Options = &options.Options{Debug: true}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func pipeName(containerID, processID, name string) string {
|
||||
return fmt.Sprintf(`\\.\pipe\containerd-%s-%s-%s`, containerID, processID, name)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue