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 {
|
2015-12-11 19:27:33 +00:00
|
|
|
if i, ok := h.s.containers[e.ID]; ok {
|
|
|
|
if err := h.deleteContainer(i.container); err != nil {
|
2015-12-01 18:55:13 +00:00
|
|
|
logrus.WithField("error", err).Error("containerd: deleting container")
|
|
|
|
}
|
2015-12-14 22:15:26 +00:00
|
|
|
if i.copier != nil {
|
|
|
|
if err := i.copier.Close(); err != nil {
|
|
|
|
logrus.WithField("error", err).Error("containerd: close container copier")
|
2015-12-11 19:56:01 +00:00
|
|
|
}
|
2015-12-11 19:27:33 +00:00
|
|
|
}
|
2015-12-10 22:11:00 +00:00
|
|
|
h.s.notifySubscribers(&Event{
|
2015-12-10 20:30:04 +00:00
|
|
|
Type: ExitEventType,
|
|
|
|
ID: e.ID,
|
|
|
|
Status: e.Status,
|
|
|
|
Pid: e.Pid,
|
|
|
|
})
|
2015-12-04 23:12:57 +00:00
|
|
|
ContainersCounter.Dec(1)
|
|
|
|
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()
|
|
|
|
}
|