2015-12-01 18:55:13 +00:00
|
|
|
package containerd
|
|
|
|
|
2015-12-01 19:56:08 +00:00
|
|
|
import "github.com/docker/containerd/runtime"
|
|
|
|
|
2015-12-01 18:55:13 +00:00
|
|
|
type UpdateEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *UpdateEvent) Handle(e *Event) error {
|
|
|
|
container, ok := h.s.containers[e.ID]
|
|
|
|
if !ok {
|
|
|
|
return ErrContainerNotFound
|
|
|
|
}
|
|
|
|
if e.State.Status != "" {
|
|
|
|
switch e.State.Status {
|
2015-12-01 19:56:08 +00:00
|
|
|
case runtime.Running:
|
2015-12-01 18:55:13 +00:00
|
|
|
if err := container.Resume(); err != nil {
|
|
|
|
return ErrUnknownContainerStatus
|
|
|
|
}
|
2015-12-01 19:56:08 +00:00
|
|
|
case runtime.Paused:
|
2015-12-01 18:55:13 +00:00
|
|
|
if err := container.Pause(); err != nil {
|
|
|
|
return ErrUnknownContainerStatus
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return ErrUnknownContainerStatus
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|