client_windows.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package remote // import "github.com/docker/docker/libcontainerd/remote"
  2. import (
  3. "context"
  4. "fmt"
  5. "os"
  6. "path/filepath"
  7. "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
  8. "github.com/containerd/containerd"
  9. "github.com/containerd/containerd/cio"
  10. "github.com/containerd/containerd/containers"
  11. libcontainerdtypes "github.com/docker/docker/libcontainerd/types"
  12. specs "github.com/opencontainers/runtime-spec/specs-go"
  13. "github.com/pkg/errors"
  14. )
  15. const runtimeName = "io.containerd.runhcs.v1"
  16. func summaryFromInterface(i interface{}) (*libcontainerdtypes.Summary, error) {
  17. switch pd := i.(type) {
  18. case *options.ProcessDetails:
  19. return &libcontainerdtypes.Summary{
  20. ImageName: pd.ImageName,
  21. CreatedAt: pd.CreatedAt,
  22. KernelTime_100Ns: pd.KernelTime_100Ns,
  23. MemoryCommitBytes: pd.MemoryCommitBytes,
  24. MemoryWorkingSetPrivateBytes: pd.MemoryWorkingSetPrivateBytes,
  25. MemoryWorkingSetSharedBytes: pd.MemoryWorkingSetSharedBytes,
  26. ProcessID: pd.ProcessID,
  27. UserTime_100Ns: pd.UserTime_100Ns,
  28. ExecID: pd.ExecID,
  29. }, nil
  30. default:
  31. return nil, errors.Errorf("Unknown process details type %T", pd)
  32. }
  33. }
  34. // WithBundle creates the bundle for the container
  35. func WithBundle(bundleDir string, ociSpec *specs.Spec) containerd.NewContainerOpts {
  36. return func(ctx context.Context, client *containerd.Client, c *containers.Container) error {
  37. // TODO: (containerd) Determine if we need to use system.MkdirAllWithACL here
  38. return os.MkdirAll(bundleDir, 0755)
  39. }
  40. }
  41. func pipeName(containerID, processID, name string) string {
  42. return fmt.Sprintf(`\\.\pipe\containerd-%s-%s-%s`, containerID, processID, name)
  43. }
  44. func newFIFOSet(bundleDir, processID string, withStdin, withTerminal bool) *cio.FIFOSet {
  45. containerID := filepath.Base(bundleDir)
  46. config := cio.Config{
  47. Terminal: withTerminal,
  48. Stdout: pipeName(containerID, processID, "stdout"),
  49. }
  50. if withStdin {
  51. config.Stdin = pipeName(containerID, processID, "stdin")
  52. }
  53. if !config.Terminal {
  54. config.Stderr = pipeName(containerID, processID, "stderr")
  55. }
  56. return cio.NewFIFOSet(config, nil)
  57. }
  58. func (c *client) newDirectIO(ctx context.Context, fifos *cio.FIFOSet) (*cio.DirectIO, error) {
  59. pipes, err := c.newStdioPipes(fifos)
  60. if err != nil {
  61. return nil, err
  62. }
  63. return cio.NewDirectIOFromFIFOSet(ctx, pipes.stdin, pipes.stdout, pipes.stderr, fifos), nil
  64. }
  65. func (c *client) UpdateResources(ctx context.Context, containerID string, resources *libcontainerdtypes.Resources) error {
  66. // TODO: (containerd): Not implemented, but don't error.
  67. return nil
  68. }
  69. func getSpecUser(ociSpec *specs.Spec) (int, int) {
  70. // TODO: (containerd): Not implemented, but don't error.
  71. // Not clear if we can even do this for LCOW.
  72. return 0, 0
  73. }