From 94568b7a9b59ab65eb7a9cbf7fb8db224d5e498c Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Fri, 11 Mar 2016 16:40:42 -0800 Subject: [PATCH] Don't send exit event on failure Signed-off-by: Michael Crosby --- supervisor/delete.go | 23 +++++++++++++---------- supervisor/worker.go | 3 ++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/supervisor/delete.go b/supervisor/delete.go index 0ff348c..ba5fbb8 100644 --- a/supervisor/delete.go +++ b/supervisor/delete.go @@ -9,9 +9,10 @@ import ( type DeleteTask struct { baseTask - ID string - Status int - PID string + ID string + Status int + PID string + NoEvent bool } func (s *Supervisor) delete(t *DeleteTask) error { @@ -20,13 +21,15 @@ func (s *Supervisor) delete(t *DeleteTask) error { if err := s.deleteContainer(i.container); err != nil { logrus.WithField("error", err).Error("containerd: deleting container") } - s.notifySubscribers(Event{ - Type: "exit", - Timestamp: time.Now(), - ID: t.ID, - Status: t.Status, - PID: t.PID, - }) + if !t.NoEvent { + s.notifySubscribers(Event{ + Type: "exit", + Timestamp: time.Now(), + ID: t.ID, + Status: t.Status, + PID: t.PID, + }) + } ContainersCounter.Dec(1) ContainerDeleteTimer.UpdateSince(start) } diff --git a/supervisor/worker.go b/supervisor/worker.go index fec1815..88314ff 100644 --- a/supervisor/worker.go +++ b/supervisor/worker.go @@ -46,7 +46,8 @@ func (w *worker) Start() { }).Error("containerd: start container") t.Err <- err evt := &DeleteTask{ - ID: t.Container.ID(), + ID: t.Container.ID(), + NoEvent: true, } w.s.SendTask(evt) continue