Stop stats collection on container exit

Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
Alexander Morozov 2015-12-16 09:39:28 -08:00
parent ab9be566cf
commit 188eeae376
4 changed files with 20 additions and 1 deletions

View File

@ -22,7 +22,8 @@ const (
CreateCheckpointEventType EventType = "createCheckpoint"
DeleteCheckpointEventType EventType = "deleteCheckpoint"
StatsEventType EventType = "events"
UnsubscribeStatsEventType EventType = "unsubscribeEvents"
UnsubscribeStatsEventType EventType = "unsubscribeStats"
StopStatsEventType EventType = "stopStats"
OOMEventType EventType = "oom"
)

View File

@ -32,6 +32,10 @@ func (h *ExitEvent) Handle(e *Event) error {
ne.Pid = e.Pid
ne.Status = e.Status
h.s.SendEvent(ne)
stopCollect := NewEvent(StopStatsEventType)
stopCollect.ID = container.ID()
h.s.SendEvent(stopCollect)
return nil
}

View File

@ -26,6 +26,10 @@ type UnsubscribeStatsEvent struct {
s *Supervisor
}
type StopStatsEvent struct {
s *Supervisor
}
func (h *StatsEvent) Handle(e *Event) error {
i, ok := h.s.containers[e.ID]
if !ok {
@ -43,3 +47,12 @@ func (h *UnsubscribeStatsEvent) Handle(e *Event) error {
h.s.statsCollector.unsubscribe(i.container, e.Stats)
return nil
}
func (h *StopStatsEvent) Handle(e *Event) error {
i, ok := h.s.containers[e.ID]
if !ok {
return ErrContainerNotFound
}
h.s.statsCollector.stopCollection(i.container)
return nil
}

View File

@ -58,6 +58,7 @@ func NewSupervisor(id, stateDir string, tasks chan *StartTask, oom bool) (*Super
DeleteCheckpointEventType: &DeleteCheckpointEvent{s},
StatsEventType: &StatsEvent{s},
UnsubscribeStatsEventType: &UnsubscribeStatsEvent{s},
StopStatsEventType: &StopStatsEvent{s},
}
// start the container workers for concurrent container starts
return s, nil