diff --git a/supervisor/checkpoint.go b/supervisor/checkpoint.go index 640f8be..466a35a 100644 --- a/supervisor/checkpoint.go +++ b/supervisor/checkpoint.go @@ -1,3 +1,5 @@ +// +build !windows + package supervisor import "github.com/docker/containerd/runtime" diff --git a/supervisor/create.go b/supervisor/create.go index 165d161..68ea707 100644 --- a/supervisor/create.go +++ b/supervisor/create.go @@ -8,13 +8,13 @@ import ( type StartTask struct { baseTask + platformStartTask ID string BundlePath string Stdout string Stderr string Stdin string StartResponse chan StartResponse - Checkpoint *runtime.Checkpoint Labels []string } @@ -36,9 +36,8 @@ func (s *Supervisor) start(t *StartTask) error { Stdout: t.Stdout, Stderr: t.Stderr, } - if t.Checkpoint != nil { - task.Checkpoint = t.Checkpoint.Name - } + task.setTaskCheckpoint(t) + s.startTasks <- task ContainerCreateTimer.UpdateSince(start) return errDeferedResponse diff --git a/supervisor/create_linux.go b/supervisor/create_linux.go new file mode 100644 index 0000000..67c570c --- /dev/null +++ b/supervisor/create_linux.go @@ -0,0 +1,13 @@ +package supervisor + +import "github.com/docker/containerd/runtime" + +type platformStartTask struct { + Checkpoint *runtime.Checkpoint +} + +func (task *startTask) setTaskCheckpoint(t *StartTask) { + if t.Checkpoint != nil { + task.Checkpoint = t.Checkpoint.Name + } +} diff --git a/supervisor/create_windows.go b/supervisor/create_windows.go new file mode 100644 index 0000000..2d76396 --- /dev/null +++ b/supervisor/create_windows.go @@ -0,0 +1,8 @@ +package supervisor + +type platformStartTask struct { +} + +// Checkpoint not supported on Windows +func (task *startTask) setTaskCheckpoint(t *StartTask) { +} diff --git a/supervisor/monitor.go b/supervisor/monitor_linux.go similarity index 100% rename from supervisor/monitor.go rename to supervisor/monitor_linux.go diff --git a/supervisor/monitor_windows.go b/supervisor/monitor_windows.go new file mode 100644 index 0000000..74c8416 --- /dev/null +++ b/supervisor/monitor_windows.go @@ -0,0 +1,33 @@ +package supervisor + +import ( + "errors" + + "github.com/docker/containerd/runtime" +) + +// TODO Windows: This is going to be very problematic to port to Windows. +// Windows golang has no concept of EpollEvent/EpollCtl etc as in the +// Linux implementation. @crosbymichael - Help needed. + +func NewMonitor() (*Monitor, error) { + return nil, errors.New("NewMonitor not implemented on Windows") +} + +type Monitor struct { +} + +func (m *Monitor) Exits() chan runtime.Process { + return nil +} + +func (m *Monitor) Monitor(p runtime.Process) error { + return errors.New("Monitor not implemented on Windows") +} + +func (m *Monitor) Close() error { + return errors.New("Monitor Close() not implemented on Windows") +} + +func (m *Monitor) start() { +} diff --git a/supervisor/supervisor.go b/supervisor/supervisor.go index e961eb2..4ff9b53 100644 --- a/supervisor/supervisor.go +++ b/supervisor/supervisor.go @@ -216,42 +216,6 @@ func (s *Supervisor) Start() error { return nil } -func (s *Supervisor) handleTask(i Task) { - var err error - switch t := i.(type) { - case *AddProcessTask: - err = s.addProcess(t) - case *CreateCheckpointTask: - err = s.createCheckpoint(t) - case *DeleteCheckpointTask: - err = s.deleteCheckpoint(t) - case *StartTask: - err = s.start(t) - case *DeleteTask: - err = s.delete(t) - case *ExitTask: - err = s.exit(t) - case *ExecExitTask: - err = s.execExit(t) - case *GetContainersTask: - err = s.getContainers(t) - case *SignalTask: - err = s.signal(t) - case *StatsTask: - err = s.stats(t) - case *UpdateTask: - err = s.updateContainer(t) - case *UpdateProcessTask: - err = s.updateProcess(t) - default: - err = ErrUnknownTask - } - if err != errDeferedResponse { - i.ErrorCh() <- err - close(i.ErrorCh()) - } -} - // Machine returns the machine information for which the // supervisor is executing on. func (s *Supervisor) Machine() Machine { diff --git a/supervisor/supervisor_linux.go b/supervisor/supervisor_linux.go new file mode 100644 index 0000000..775fd17 --- /dev/null +++ b/supervisor/supervisor_linux.go @@ -0,0 +1,37 @@ +package supervisor + +func (s *Supervisor) handleTask(i Task) { + var err error + switch t := i.(type) { + case *AddProcessTask: + err = s.addProcess(t) + case *CreateCheckpointTask: + err = s.createCheckpoint(t) + case *DeleteCheckpointTask: + err = s.deleteCheckpoint(t) + case *StartTask: + err = s.start(t) + case *DeleteTask: + err = s.delete(t) + case *ExitTask: + err = s.exit(t) + case *ExecExitTask: + err = s.execExit(t) + case *GetContainersTask: + err = s.getContainers(t) + case *SignalTask: + err = s.signal(t) + case *StatsTask: + err = s.stats(t) + case *UpdateTask: + err = s.updateContainer(t) + case *UpdateProcessTask: + err = s.updateProcess(t) + default: + err = ErrUnknownTask + } + if err != errDeferedResponse { + i.ErrorCh() <- err + close(i.ErrorCh()) + } +} diff --git a/supervisor/supervisor_windows.go b/supervisor/supervisor_windows.go new file mode 100644 index 0000000..66c4ada --- /dev/null +++ b/supervisor/supervisor_windows.go @@ -0,0 +1,33 @@ +package supervisor + +func (s *Supervisor) handleTask(i Task) { + var err error + switch t := i.(type) { + case *AddProcessTask: + err = s.addProcess(t) + case *StartTask: + err = s.start(t) + case *DeleteTask: + err = s.delete(t) + case *ExitTask: + err = s.exit(t) + case *ExecExitTask: + err = s.execExit(t) + case *GetContainersTask: + err = s.getContainers(t) + case *SignalTask: + err = s.signal(t) + case *StatsTask: + err = s.stats(t) + case *UpdateTask: + err = s.updateContainer(t) + case *UpdateProcessTask: + err = s.updateProcess(t) + default: + err = ErrUnknownTask + } + if err != errDeferedResponse { + i.ErrorCh() <- err + close(i.ErrorCh()) + } +}