2015-12-01 18:55:13 +00:00
|
|
|
package containerd
|
|
|
|
|
2015-12-01 19:56:08 +00:00
|
|
|
import (
|
|
|
|
"github.com/Sirupsen/logrus"
|
|
|
|
"github.com/docker/containerd/runtime"
|
|
|
|
)
|
2015-12-01 18:55:13 +00:00
|
|
|
|
|
|
|
type DeleteEvent struct {
|
|
|
|
s *Supervisor
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *DeleteEvent) Handle(e *Event) error {
|
|
|
|
if container, ok := h.s.containers[e.ID]; ok {
|
|
|
|
if err := h.deleteContainer(container); err != nil {
|
|
|
|
logrus.WithField("error", err).Error("containerd: deleting container")
|
|
|
|
}
|
|
|
|
ContainersCounter.Dec(1)
|
2015-12-04 21:31:17 +00:00
|
|
|
h.s.containerGroup.Done()
|
2015-12-01 18:55:13 +00:00
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-12-01 19:56:08 +00:00
|
|
|
func (h *DeleteEvent) deleteContainer(container runtime.Container) error {
|
2015-12-01 18:55:13 +00:00
|
|
|
delete(h.s.containers, container.ID())
|
|
|
|
return container.Delete()
|
|
|
|
}
|