containerd/supervisor/stats.go
Kenfe-Mickael Laventure b7042518e5 Fix stats command not returning
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
2016-02-25 10:14:20 -08:00

33 lines
538 B
Go

package supervisor
import (
"time"
"github.com/docker/containerd/runtime"
)
type StatsTask struct {
baseTask
ID string
Stat chan *runtime.Stat
}
func (s *Supervisor) stats(t *StatsTask) error {
start := time.Now()
i, ok := s.containers[t.ID]
if !ok {
return ErrContainerNotFound
}
// TODO: use workers for this
go func() {
s, err := i.container.Stats()
if err != nil {
t.ErrorCh() <- err
return
}
t.ErrorCh() <- nil
t.Stat <- s
ContainerStatsTimer.UpdateSince(start)
}()
return errDeferedResponse
}