mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove jobs from stats
Signed-off-by: Antonio Murdaca <me@runcom.ninja>
This commit is contained in:
parent
a54fd325e6
commit
65a056345c
3 changed files with 9 additions and 10 deletions
|
@ -543,10 +543,10 @@ func getContainersStats(eng *engine.Engine, version version.Version, w http.Resp
|
|||
if vars == nil {
|
||||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
name := vars["name"]
|
||||
job := eng.Job("container_stats", name)
|
||||
streamJSON(job, w, true)
|
||||
return job.Run()
|
||||
|
||||
d := getDaemon(eng)
|
||||
|
||||
return d.ContainerStats(vars["name"], utils.NewWriteFlusher(w))
|
||||
}
|
||||
|
||||
func getContainersLogs(eng *engine.Engine, version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
|
|
|
@ -119,7 +119,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
|
|||
for name, method := range map[string]engine.Handler{
|
||||
"commit": daemon.ContainerCommit,
|
||||
"container_inspect": daemon.ContainerInspect,
|
||||
"container_stats": daemon.ContainerStats,
|
||||
"create": daemon.ContainerCreate,
|
||||
"export": daemon.ContainerExport,
|
||||
"info": daemon.CmdInfo,
|
||||
|
|
|
@ -2,20 +2,20 @@ package daemon
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/daemon/execdriver"
|
||||
"github.com/docker/docker/engine"
|
||||
"github.com/docker/libcontainer"
|
||||
"github.com/docker/libcontainer/cgroups"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) ContainerStats(job *engine.Job) error {
|
||||
updates, err := daemon.SubscribeToContainerStats(job.Args[0])
|
||||
func (daemon *Daemon) ContainerStats(name string, out io.Writer) error {
|
||||
updates, err := daemon.SubscribeToContainerStats(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
enc := json.NewEncoder(job.Stdout)
|
||||
enc := json.NewEncoder(out)
|
||||
for v := range updates {
|
||||
update := v.(*execdriver.ResourceStats)
|
||||
ss := convertToAPITypes(update.Stats)
|
||||
|
@ -24,7 +24,7 @@ func (daemon *Daemon) ContainerStats(job *engine.Job) error {
|
|||
ss.CpuStats.SystemUsage = update.SystemUsage
|
||||
if err := enc.Encode(ss); err != nil {
|
||||
// TODO: handle the specific broken pipe
|
||||
daemon.UnsubscribeToContainerStats(job.Args[0], updates)
|
||||
daemon.UnsubscribeToContainerStats(name, updates)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue