github.com/runcom/containerd@v0.0.0-20160708090337-9bff9f934c0d/supervisor/delete.go (about) 1 package supervisor 2 3 import ( 4 "time" 5 6 "github.com/Sirupsen/logrus" 7 "github.com/docker/containerd/runtime" 8 ) 9 10 // DeleteTask holds needed parameters to remove a container 11 type DeleteTask struct { 12 baseTask 13 ID string 14 Status int 15 PID string 16 NoEvent bool 17 } 18 19 func (s *Supervisor) delete(t *DeleteTask) error { 20 if i, ok := s.containers[t.ID]; ok { 21 start := time.Now() 22 if err := s.deleteContainer(i.container); err != nil { 23 logrus.WithField("error", err).Error("containerd: deleting container") 24 } 25 if !t.NoEvent { 26 s.notifySubscribers(Event{ 27 Type: StateExit, 28 Timestamp: time.Now(), 29 ID: t.ID, 30 Status: t.Status, 31 PID: t.PID, 32 }) 33 } 34 ContainersCounter.Dec(1) 35 ContainerDeleteTimer.UpdateSince(start) 36 } 37 return nil 38 } 39 40 func (s *Supervisor) deleteContainer(container runtime.Container) error { 41 delete(s.containers, container.ID()) 42 return container.Delete() 43 }