Stop stats collection on container exit
Signed-off-by: Alexander Morozov <lk4d4@docker.com>
This commit is contained in:
parent
ab9be566cf
commit
188eeae376
4 changed files with 20 additions and 1 deletions
3
event.go
3
event.go
|
@ -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"
|
||||
)
|
||||
|
||||
|
|
4
exit.go
4
exit.go
|
@ -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
|
||||
}
|
||||
|
||||
|
|
13
stats.go
13
stats.go
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue