From 65a056345cec1b85bd41ed70ee814894709ee6c0 Mon Sep 17 00:00:00 2001 From: Antonio Murdaca Date: Mon, 13 Apr 2015 08:33:53 +0200 Subject: [PATCH] Remove jobs from stats Signed-off-by: Antonio Murdaca --- api/server/server.go | 8 ++++---- daemon/daemon.go | 1 - daemon/stats.go | 10 +++++----- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/api/server/server.go b/api/server/server.go index d1f9b18946..840c656b19 100644 --- a/api/server/server.go +++ b/api/server/server.go @@ -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 { diff --git a/daemon/daemon.go b/daemon/daemon.go index 40d1ecb418..290a9bebec 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -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, diff --git a/daemon/stats.go b/daemon/stats.go index e40788013f..a95168d128 100644 --- a/daemon/stats.go +++ b/daemon/stats.go @@ -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 } }