From 2b8f0229504a6c05db7b30f3e8ba793caec85fd2 Mon Sep 17 00:00:00 2001 From: John Howard Date: Thu, 25 Feb 2016 18:39:03 -0800 Subject: [PATCH] runtime compiles on Windows Signed-off-by: John Howard --- api/grpc/server/server.go | 2 +- runtime/container.go | 202 +--------------------------------- runtime/container_linux.go | 206 ++++++++++++++++++++++++++++++++++- runtime/container_windows.go | 46 +++++++- runtime/process.go | 27 ++--- runtime/process_linux.go | 15 +++ runtime/process_windows.go | 10 ++ runtime/runtime.go | 32 ++---- runtime/runtime_linux.go | 25 +++++ runtime/runtime_windows.go | 10 ++ runtime/spec_linux.go | 3 +- runtime/spec_windows.go | 34 +----- specs/unsupported.go | 3 + specs/windows.go | 48 ++++++++ supervisor/add_process.go | 3 +- supervisor/sort_test.go | 5 +- 16 files changed, 390 insertions(+), 281 deletions(-) create mode 100644 runtime/runtime_linux.go create mode 100644 runtime/runtime_windows.go create mode 100644 specs/unsupported.go create mode 100644 specs/windows.go diff --git a/api/grpc/server/server.go b/api/grpc/server/server.go index d1227be..9fc8180 100644 --- a/api/grpc/server/server.go +++ b/api/grpc/server/server.go @@ -78,7 +78,7 @@ func (s *apiServer) Signal(ctx context.Context, r *types.SignalRequest) (*types. } func (s *apiServer) AddProcess(ctx context.Context, r *types.AddProcessRequest) (*types.AddProcessResponse, error) { - process := &specs.Process{ + process := &runtime.ProcessSpec{ Terminal: r.Terminal, Args: r.Args, Env: r.Env, diff --git a/runtime/container.go b/runtime/container.go index f0b6db4..d07b69b 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -4,14 +4,9 @@ import ( "encoding/json" "io/ioutil" "os" - "os/exec" "path/filepath" - "syscall" - "time" "github.com/Sirupsen/logrus" - "github.com/opencontainers/runc/libcontainer" - "github.com/opencontainers/specs" ) type Container interface { @@ -22,7 +17,7 @@ type Container interface { // Start starts the init process of the container Start(checkpoint string, s Stdio) (Process, error) // Exec starts another process in an existing container - Exec(string, specs.Process, Stdio) (Process, error) + Exec(string, ProcessSpec, Stdio) (Process, error) // Delete removes the container's state and any resources Delete() error // Processes returns all the containers processes that have been added @@ -173,81 +168,8 @@ func (c *container) Labels() []string { return c.labels } -func (c *container) Start(checkpoint string, s Stdio) (Process, error) { - processRoot := filepath.Join(c.root, c.id, InitProcessID) - if err := os.Mkdir(processRoot, 0755); err != nil { - return nil, err - } - cmd := exec.Command("containerd-shim", - c.id, c.bundle, - ) - cmd.Dir = processRoot - cmd.SysProcAttr = &syscall.SysProcAttr{ - Setpgid: true, - } - spec, err := c.readSpec() - if err != nil { - return nil, err - } - config := &processConfig{ - checkpoint: checkpoint, - root: processRoot, - id: InitProcessID, - c: c, - stdio: s, - spec: spec, - processSpec: spec.Process, - } - p, err := newProcess(config) - if err != nil { - return nil, err - } - if err := cmd.Start(); err != nil { - return nil, err - } - if _, err := p.getPid(); err != nil { - return p, nil - } - c.processes[InitProcessID] = p - return p, nil -} - -func (c *container) Exec(pid string, spec specs.Process, s Stdio) (Process, error) { - processRoot := filepath.Join(c.root, c.id, pid) - if err := os.Mkdir(processRoot, 0755); err != nil { - return nil, err - } - cmd := exec.Command("containerd-shim", - c.id, c.bundle, - ) - cmd.Dir = processRoot - cmd.SysProcAttr = &syscall.SysProcAttr{ - Setpgid: true, - } - config := &processConfig{ - exec: true, - id: pid, - root: processRoot, - c: c, - processSpec: spec, - stdio: s, - } - p, err := newProcess(config) - if err != nil { - return nil, err - } - if err := cmd.Start(); err != nil { - return nil, err - } - if _, err := p.getPid(); err != nil { - return p, nil - } - c.processes[pid] = p - return p, nil -} - -func (c *container) readSpec() (*platformSpec, error) { - var spec platformSpec +func (c *container) readSpec() (*PlatformSpec, error) { + var spec PlatformSpec f, err := os.Open(filepath.Join(c.bundle, "config.json")) if err != nil { return nil, err @@ -259,14 +181,6 @@ func (c *container) readSpec() (*platformSpec, error) { return &spec, nil } -func (c *container) Pause() error { - return exec.Command("runc", "pause", c.id).Run() -} - -func (c *container) Resume() error { - return exec.Command("runc", "resume", c.id).Run() -} - func (c *container) State() State { return Running } @@ -287,113 +201,3 @@ func (c *container) RemoveProcess(pid string) error { delete(c.processes, pid) return os.RemoveAll(filepath.Join(c.root, c.id, pid)) } - -func (c *container) Checkpoints() ([]Checkpoint, error) { - dirs, err := ioutil.ReadDir(filepath.Join(c.bundle, "checkpoints")) - if err != nil { - return nil, err - } - var out []Checkpoint - for _, d := range dirs { - if !d.IsDir() { - continue - } - path := filepath.Join(c.bundle, "checkpoints", d.Name(), "config.json") - data, err := ioutil.ReadFile(path) - if err != nil { - return nil, err - } - var cpt Checkpoint - if err := json.Unmarshal(data, &cpt); err != nil { - return nil, err - } - out = append(out, cpt) - } - return out, nil -} - -func (c *container) Checkpoint(cpt Checkpoint) error { - if err := os.MkdirAll(filepath.Join(c.bundle, "checkpoints"), 0755); err != nil { - return err - } - path := filepath.Join(c.bundle, "checkpoints", cpt.Name) - if err := os.Mkdir(path, 0755); err != nil { - return err - } - f, err := os.Create(filepath.Join(path, "config.json")) - if err != nil { - return err - } - cpt.Created = time.Now() - err = json.NewEncoder(f).Encode(cpt) - f.Close() - if err != nil { - return err - } - args := []string{ - "checkpoint", - "--image-path", path, - } - add := func(flags ...string) { - args = append(args, flags...) - } - if !cpt.Exit { - add("--leave-running") - } - if cpt.Shell { - add("--shell-job") - } - if cpt.Tcp { - add("--tcp-established") - } - if cpt.UnixSockets { - add("--ext-unix-sk") - } - add(c.id) - return exec.Command("runc", args...).Run() -} - -func (c *container) DeleteCheckpoint(name string) error { - return os.RemoveAll(filepath.Join(c.bundle, "checkpoints", name)) -} - -func (c *container) Pids() ([]int, error) { - container, err := c.getLibctContainer() - if err != nil { - return nil, err - } - return container.Processes() -} - -func (c *container) Stats() (*Stat, error) { - container, err := c.getLibctContainer() - if err != nil { - return nil, err - } - now := time.Now() - stats, err := container.Stats() - if err != nil { - return nil, err - } - return &Stat{ - Timestamp: now, - Data: stats, - }, nil -} - -func (c *container) getLibctContainer() (libcontainer.Container, error) { - f, err := libcontainer.New(specs.LinuxStateDirectory, libcontainer.Cgroupfs) - if err != nil { - return nil, err - } - return f.Load(c.id) -} - -func hostIDFromMap(id uint32, mp []specs.IDMapping) int { - for _, m := range mp { - if (id >= m.ContainerID) && (id <= (m.ContainerID + m.Size - 1)) { - return int(m.HostID + (id - m.ContainerID)) - } - } - return 0 -} diff --git a/runtime/container_linux.go b/runtime/container_linux.go index 1c0fbef..1734977 100644 --- a/runtime/container_linux.go +++ b/runtime/container_linux.go @@ -1,8 +1,19 @@ package runtime -import "github.com/opencontainers/specs" +import ( + "encoding/json" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "syscall" + "time" -func getRootIDs(s *platformSpec) (int, int, error) { + "github.com/opencontainers/runc/libcontainer" + "github.com/opencontainers/specs" +) + +func getRootIDs(s *PlatformSpec) (int, int, error) { if s == nil { return 0, 0, nil } @@ -20,3 +31,194 @@ func getRootIDs(s *platformSpec) (int, int, error) { gid := hostIDFromMap(0, s.Linux.GIDMappings) return uid, gid, nil } + +func (c *container) Pause() error { + return exec.Command("runc", "pause", c.id).Run() +} + +func (c *container) Resume() error { + return exec.Command("runc", "resume", c.id).Run() +} + +func (c *container) Checkpoints() ([]Checkpoint, error) { + dirs, err := ioutil.ReadDir(filepath.Join(c.bundle, "checkpoints")) + if err != nil { + return nil, err + } + var out []Checkpoint + for _, d := range dirs { + if !d.IsDir() { + continue + } + path := filepath.Join(c.bundle, "checkpoints", d.Name(), "config.json") + data, err := ioutil.ReadFile(path) + if err != nil { + return nil, err + } + var cpt Checkpoint + if err := json.Unmarshal(data, &cpt); err != nil { + return nil, err + } + out = append(out, cpt) + } + return out, nil +} + +func (c *container) Checkpoint(cpt Checkpoint) error { + if err := os.MkdirAll(filepath.Join(c.bundle, "checkpoints"), 0755); err != nil { + return err + } + path := filepath.Join(c.bundle, "checkpoints", cpt.Name) + if err := os.Mkdir(path, 0755); err != nil { + return err + } + f, err := os.Create(filepath.Join(path, "config.json")) + if err != nil { + return err + } + cpt.Created = time.Now() + err = json.NewEncoder(f).Encode(cpt) + f.Close() + if err != nil { + return err + } + args := []string{ + "checkpoint", + "--image-path", path, + } + add := func(flags ...string) { + args = append(args, flags...) + } + if !cpt.Exit { + add("--leave-running") + } + if cpt.Shell { + add("--shell-job") + } + if cpt.Tcp { + add("--tcp-established") + } + if cpt.UnixSockets { + add("--ext-unix-sk") + } + add(c.id) + return exec.Command("runc", args...).Run() +} + +func (c *container) DeleteCheckpoint(name string) error { + return os.RemoveAll(filepath.Join(c.bundle, "checkpoints", name)) +} + +func (c *container) Start(checkpoint string, s Stdio) (Process, error) { + processRoot := filepath.Join(c.root, c.id, InitProcessID) + if err := os.Mkdir(processRoot, 0755); err != nil { + return nil, err + } + cmd := exec.Command("containerd-shim", + c.id, c.bundle, + ) + cmd.Dir = processRoot + cmd.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, + } + spec, err := c.readSpec() + if err != nil { + return nil, err + } + config := &processConfig{ + checkpoint: checkpoint, + root: processRoot, + id: InitProcessID, + c: c, + stdio: s, + spec: spec, + processSpec: ProcessSpec(spec.Process), + } + p, err := newProcess(config) + if err != nil { + return nil, err + } + if err := cmd.Start(); err != nil { + return nil, err + } + if _, err := p.getPid(); err != nil { + return p, nil + } + c.processes[InitProcessID] = p + return p, nil +} + +func (c *container) Exec(pid string, spec ProcessSpec, s Stdio) (Process, error) { + processRoot := filepath.Join(c.root, c.id, pid) + if err := os.Mkdir(processRoot, 0755); err != nil { + return nil, err + } + cmd := exec.Command("containerd-shim", + c.id, c.bundle, + ) + cmd.Dir = processRoot + cmd.SysProcAttr = &syscall.SysProcAttr{ + Setpgid: true, + } + config := &processConfig{ + exec: true, + id: pid, + root: processRoot, + c: c, + processSpec: spec, + stdio: s, + } + p, err := newProcess(config) + if err != nil { + return nil, err + } + if err := cmd.Start(); err != nil { + return nil, err + } + if _, err := p.getPid(); err != nil { + return p, nil + } + c.processes[pid] = p + return p, nil +} + +func (c *container) getLibctContainer() (libcontainer.Container, error) { + f, err := libcontainer.New(specs.LinuxStateDirectory, libcontainer.Cgroupfs) + if err != nil { + return nil, err + } + return f.Load(c.id) +} + +func hostIDFromMap(id uint32, mp []specs.IDMapping) int { + for _, m := range mp { + if (id >= m.ContainerID) && (id <= (m.ContainerID + m.Size - 1)) { + return int(m.HostID + (id - m.ContainerID)) + } + } + return 0 +} + +func (c *container) Pids() ([]int, error) { + container, err := c.getLibctContainer() + if err != nil { + return nil, err + } + return container.Processes() +} + +func (c *container) Stats() (*Stat, error) { + container, err := c.getLibctContainer() + if err != nil { + return nil, err + } + now := time.Now() + stats, err := container.Stats() + if err != nil { + return nil, err + } + return &Stat{ + Timestamp: now, + Data: stats, + }, nil +} diff --git a/runtime/container_windows.go b/runtime/container_windows.go index d9ae7a0..7d04653 100644 --- a/runtime/container_windows.go +++ b/runtime/container_windows.go @@ -1,5 +1,49 @@ package runtime -func getRootIDs(s *platformSpec) (int, int, error) { +import "errors" + +func getRootIDs(s *PlatformSpec) (int, int, error) { return 0, 0, nil } + +func (c *container) Pause() error { + return errors.New("Pause not supported on Windows") +} + +func (c *container) Resume() error { + return errors.New("Resume not supported on Windows") +} + +func (c *container) Checkpoints() ([]Checkpoint, error) { + return nil, errors.New("Checkpoints not supported on Windows ") +} + +func (c *container) Checkpoint(cpt Checkpoint) error { + return errors.New("Checkpoint not supported on Windows ") +} + +func (c *container) DeleteCheckpoint(name string) error { + return errors.New("DeleteCheckpoint not supported on Windows ") +} + +// TODO Windows: Implement me. +// This will have a very different implementation on Windows. +func (c *container) Start(checkpoint string, s Stdio) (Process, error) { + return nil, errors.New("Start not yet implemented on Windows") +} + +// TODO Windows: Implement me. +// This will have a very different implementation on Windows. +func (c *container) Exec(pid string, spec ProcessSpec, s Stdio) (Process, error) { + return nil, errors.New("Exec not yet implemented on Windows") +} + +// TODO Windows: Implement me. +func (c *container) Pids() ([]int, error) { + return nil, errors.New("Pids not yet implemented on Windows") +} + +// TODO Windows: Implement me. (Not yet supported by docker on Windows either...) +func (c *container) Stats() (*Stat, error) { + return nil, errors.New("Stats not yet implemented on Windows") +} diff --git a/runtime/process.go b/runtime/process.go index 46b4c33..b1c08d5 100644 --- a/runtime/process.go +++ b/runtime/process.go @@ -9,8 +9,6 @@ import ( "path/filepath" "strconv" "time" - - "github.com/opencontainers/specs" ) type Process interface { @@ -28,7 +26,7 @@ type Process interface { // has not exited ExitStatus() (int, error) // Spec returns the process spec that created the process - Spec() specs.Process + Spec() ProcessSpec // Signal sends the provided signal to the process Signal(os.Signal) error // Container returns the container that the process belongs to @@ -42,8 +40,8 @@ type Process interface { type processConfig struct { id string root string - processSpec specs.Process - spec *platformSpec + processSpec ProcessSpec + spec *PlatformSpec c *container stdio Stdio exec bool @@ -67,16 +65,9 @@ func newProcess(config *processConfig) (*process, error) { return nil, err } defer f.Close() - if err := json.NewEncoder(f).Encode(ProcessState{ - Process: config.processSpec, - Exec: config.exec, - Checkpoint: config.checkpoint, - RootUID: uid, - RootGID: gid, - Stdin: config.stdio.Stdin, - Stdout: config.stdio.Stdout, - Stderr: config.stdio.Stderr, - }); err != nil { + + ps := populateProcessStateForEncoding(config, uid, gid) + if err := json.NewEncoder(f).Encode(ps); err != nil { return nil, err } exit, err := getExitPipe(filepath.Join(config.root, ExitFile)) @@ -97,7 +88,7 @@ func loadProcess(root, id string, c *container, s *ProcessState) (*process, erro root: root, id: id, container: c, - spec: s.Process, + spec: s.ProcessSpec, stdio: Stdio{ Stdin: s.Stdin, Stdout: s.Stdout, @@ -128,7 +119,7 @@ type process struct { exitPipe *os.File controlPipe *os.File container *container - spec specs.Process + spec ProcessSpec stdio Stdio } @@ -173,7 +164,7 @@ func (p *process) ExitStatus() (int, error) { return strconv.Atoi(string(data)) } -func (p *process) Spec() specs.Process { +func (p *process) Spec() ProcessSpec { return p.spec } diff --git a/runtime/process_linux.go b/runtime/process_linux.go index 82e4940..0295ee4 100644 --- a/runtime/process_linux.go +++ b/runtime/process_linux.go @@ -25,3 +25,18 @@ func getControlPipe(path string) (*os.File, error) { func (p *process) Signal(s os.Signal) error { return syscall.Kill(p.pid, s.(syscall.Signal)) } + +func populateProcessStateForEncoding(config *processConfig, uid int, gid int) ProcessState { + return ProcessState{ + ProcessSpec: config.processSpec, + Exec: config.exec, + PlatformProcessState: PlatformProcessState{ + Checkpoint: config.checkpoint, + RootUID: uid, + RootGID: gid, + }, + Stdin: config.stdio.Stdin, + Stdout: config.stdio.Stdout, + Stderr: config.stdio.Stderr, + } +} diff --git a/runtime/process_windows.go b/runtime/process_windows.go index bbeea5f..e435352 100644 --- a/runtime/process_windows.go +++ b/runtime/process_windows.go @@ -17,3 +17,13 @@ func getControlPipe(path string) (*os.File, error) { func (p *process) Signal(s os.Signal) error { return nil } + +func populateProcessStateForEncoding(config *processConfig, uid int, gid int) ProcessState { + return ProcessState{ + ProcessSpec: config.processSpec, + Exec: config.exec, + Stdin: config.stdio.Stdin, + Stdout: config.stdio.Stdout, + Stderr: config.stdio.Stderr, + } +} diff --git a/runtime/runtime.go b/runtime/runtime.go index 7ab9bc5..26d9465 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -3,8 +3,6 @@ package runtime import ( "errors" "time" - - "github.com/opencontainers/specs" ) var ( @@ -44,14 +42,13 @@ type state struct { } type ProcessState struct { - specs.Process - Exec bool `json:"exec"` - Checkpoint string `json:"checkpoint"` - RootUID int `json:"rootUID"` - RootGID int `json:"rootGID"` - Stdin string `json:"containerdStdin"` - Stdout string `json:"containerdStdout"` - Stderr string `json:"containerdStderr"` + ProcessSpec + Exec bool `json:"exec"` + Stdin string `json:"containerdStdin"` + Stdout string `json:"containerdStdout"` + Stderr string `json:"containerdStderr"` + + PlatformProcessState } type Stat struct { @@ -63,18 +60,3 @@ type Stat struct { // can return what they want and we could marshal to json or whatever. Data interface{} } - -type Checkpoint struct { - // Timestamp is the time that checkpoint happened - Created time.Time `json:"created"` - // Name is the name of the checkpoint - Name string `json:"name"` - // Tcp checkpoints open tcp connections - Tcp bool `json:"tcp"` - // UnixSockets persists unix sockets in the checkpoint - UnixSockets bool `json:"unixSockets"` - // Shell persists tty sessions in the checkpoint - Shell bool `json:"shell"` - // Exit exits the container after the checkpoint is finished - Exit bool `json:"exit"` -} diff --git a/runtime/runtime_linux.go b/runtime/runtime_linux.go new file mode 100644 index 0000000..b2d925a --- /dev/null +++ b/runtime/runtime_linux.go @@ -0,0 +1,25 @@ +package runtime + +import "time" + +type Checkpoint struct { + // Timestamp is the time that checkpoint happened + Created time.Time `json:"created"` + // Name is the name of the checkpoint + Name string `json:"name"` + // Tcp checkpoints open tcp connections + Tcp bool `json:"tcp"` + // UnixSockets persists unix sockets in the checkpoint + UnixSockets bool `json:"unixSockets"` + // Shell persists tty sessions in the checkpoint + Shell bool `json:"shell"` + // Exit exits the container after the checkpoint is finished + Exit bool `json:"exit"` +} + +// PlatformProcessState container platform-specific fields in the ProcessState structure +type PlatformProcessState struct { + Checkpoint string `json:"checkpoint"` + RootUID int `json:"rootUID"` + RootGID int `json:"rootGID"` +} diff --git a/runtime/runtime_windows.go b/runtime/runtime_windows.go new file mode 100644 index 0000000..b3d9218 --- /dev/null +++ b/runtime/runtime_windows.go @@ -0,0 +1,10 @@ +package runtime + +// Checkpoint is not supported on Windows. +// TODO Windows: Can eventually be factored out entirely. +type Checkpoint struct { +} + +// PlatformProcessState container platform-specific fields in the ProcessState structure +type PlatformProcessState struct { +} diff --git a/runtime/spec_linux.go b/runtime/spec_linux.go index 3c6bc22..d243cf4 100644 --- a/runtime/spec_linux.go +++ b/runtime/spec_linux.go @@ -2,4 +2,5 @@ package runtime import "github.com/opencontainers/specs" -type platformSpec specs.LinuxSpec +type PlatformSpec specs.LinuxSpec +type ProcessSpec specs.Process diff --git a/runtime/spec_windows.go b/runtime/spec_windows.go index 7273041..ff4a06a 100644 --- a/runtime/spec_windows.go +++ b/runtime/spec_windows.go @@ -1,32 +1,8 @@ package runtime -type Spec struct { - // Version is the version of the specification that is supported. - Version string `json:"ociVersion"` - // Platform is the host information for OS and Arch. - // TEMPORARY HACK Platform Platform `json:"platform"` - // Process is the container's main process. - // TEMPORARY HACK Process Process `json:"process"` - // Root is the root information for the container's filesystem. - // TEMPORARY HACK Root Root `json:"root"` - // Hostname is the container's host name. - // TEMPORARY HACK Hostname string `json:"hostname,omitempty"` - // Mounts profile configuration for adding mounts to the container's filesystem. - // TEMPORARY HACK Mounts []Mount `json:"mounts"` - // Hooks are the commands run at various lifecycle events of the container. - // TEMPORARY HACK Hooks Hooks `json:"hooks"` -} +// Temporary Windows version of the spec in lieu of opencontainers/specs having +// Windows support currently. +import "github.com/docker/containerd/specs" -// TODO Windows - Interim hack. Needs implementing. -type WindowsSpec struct { - Spec - - // Windows is platform specific configuration for Windows based containers. - Windows Windows `json:"windows"` -} - -// Windows contains platform specific configuration for Windows based containers. -type Windows struct { -} - -type platformSpec WindowsSpec +type PlatformSpec specs.WindowsSpec +type ProcessSpec specs.Process diff --git a/specs/unsupported.go b/specs/unsupported.go new file mode 100644 index 0000000..fdb50a2 --- /dev/null +++ b/specs/unsupported.go @@ -0,0 +1,3 @@ +// +build !windows + +package specs diff --git a/specs/windows.go b/specs/windows.go new file mode 100644 index 0000000..4871e88 --- /dev/null +++ b/specs/windows.go @@ -0,0 +1,48 @@ +package specs + +// This is a temporary module in lieu of opencontainers/specs being compatible +// currently on Windows. + +// Process contains information to start a specific application inside the container. +type Process struct { + // Terminal creates an interactive terminal for the container. + Terminal bool `json:"terminal"` + // User specifies user information for the process. + // TEMPORARY HACK User User `json:"user"` + // Args specifies the binary and arguments for the application to execute. + Args []string `json:"args"` + // Env populates the process environment for the process. + Env []string `json:"env,omitempty"` + // Cwd is the current working directory for the process and must be + // relative to the container's root. + Cwd string `json:"cwd"` +} + +type Spec struct { + // Version is the version of the specification that is supported. + Version string `json:"ociVersion"` + // Platform is the host information for OS and Arch. + // TEMPORARY HACK Platform Platform `json:"platform"` + // Process is the container's main process. + Process Process `json:"process"` + // Root is the root information for the container's filesystem. + // TEMPORARY HACK Root Root `json:"root"` + // Hostname is the container's host name. + // TEMPORARY HACK Hostname string `json:"hostname,omitempty"` + // Mounts profile configuration for adding mounts to the container's filesystem. + // TEMPORARY HACK Mounts []Mount `json:"mounts"` + // Hooks are the commands run at various lifecycle events of the container. + // TEMPORARY HACK Hooks Hooks `json:"hooks"` +} + +// Windows contains platform specific configuration for Windows based containers. +type Windows struct { +} + +// TODO Windows - Interim hack. Needs implementing. +type WindowsSpec struct { + Spec + + // Windows is platform specific configuration for Windows based containers. + Windows Windows `json:"windows"` +} diff --git a/supervisor/add_process.go b/supervisor/add_process.go index e07cac2..6a7e23f 100644 --- a/supervisor/add_process.go +++ b/supervisor/add_process.go @@ -4,7 +4,6 @@ import ( "time" "github.com/docker/containerd/runtime" - "github.com/opencontainers/specs" ) type AddProcessTask struct { @@ -14,7 +13,7 @@ type AddProcessTask struct { Stdout string Stderr string Stdin string - ProcessSpec *specs.Process + ProcessSpec *runtime.ProcessSpec StartResponse chan StartResponse } diff --git a/supervisor/sort_test.go b/supervisor/sort_test.go index 9202ac3..0a7498a 100644 --- a/supervisor/sort_test.go +++ b/supervisor/sort_test.go @@ -6,7 +6,6 @@ import ( "testing" "github.com/docker/containerd/runtime" - "github.com/opencontainers/specs" ) type testProcess struct { @@ -45,8 +44,8 @@ func (p *testProcess) Container() runtime.Container { return nil } -func (p *testProcess) Spec() specs.Process { - return specs.Process{} +func (p *testProcess) Spec() runtime.ProcessSpec { + return runtime.ProcessSpec{} } func (p *testProcess) Signal(os.Signal) error {