瀏覽代碼

Merge pull request #19946 from Microsoft/jjh/stats

Windows: Turn off stats
Vincent Demeester 9 年之前
父節點
當前提交
4ef06e9ef1
共有 2 個文件被更改,包括 11 次插入0 次删除
  1. 6 0
      daemon/stats.go
  2. 5 0
      integration-cli/docker_cli_stats_test.go

+ 6 - 0
daemon/stats.go

@@ -2,7 +2,9 @@ package daemon
 
 
 import (
 import (
 	"encoding/json"
 	"encoding/json"
+	"errors"
 	"io"
 	"io"
+	"runtime"
 
 
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/daemon/execdriver"
 	"github.com/docker/docker/pkg/version"
 	"github.com/docker/docker/pkg/version"
@@ -22,6 +24,10 @@ type ContainerStatsConfig struct {
 // ContainerStats writes information about the container to the stream
 // ContainerStats writes information about the container to the stream
 // given in the config object.
 // given in the config object.
 func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStatsConfig) error {
 func (daemon *Daemon) ContainerStats(prefixOrName string, config *ContainerStatsConfig) error {
+	if runtime.GOOS == "windows" {
+		return errors.New("Windows does not support stats")
+	}
+
 	container, err := daemon.GetContainer(prefixOrName)
 	container, err := daemon.GetContainer(prefixOrName)
 	if err != nil {
 	if err != nil {
 		return err
 		return err

+ 5 - 0
integration-cli/docker_cli_stats_test.go

@@ -12,6 +12,7 @@ import (
 )
 )
 
 
 func (s *DockerSuite) TestStatsNoStream(c *check.C) {
 func (s *DockerSuite) TestStatsNoStream(c *check.C) {
+	// Windows does not support stats
 	testRequires(c, DaemonIsLinux)
 	testRequires(c, DaemonIsLinux)
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
 	id := strings.TrimSpace(out)
 	id := strings.TrimSpace(out)
@@ -40,6 +41,7 @@ func (s *DockerSuite) TestStatsNoStream(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
 func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
+	// Windows does not support stats
 	testRequires(c, DaemonIsLinux)
 	testRequires(c, DaemonIsLinux)
 
 
 	out, _, err := dockerCmdWithError("stats", "notfound")
 	out, _, err := dockerCmdWithError("stats", "notfound")
@@ -52,6 +54,7 @@ func (s *DockerSuite) TestStatsContainerNotFound(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
 func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
+	// Windows does not support stats
 	testRequires(c, DaemonIsLinux)
 	testRequires(c, DaemonIsLinux)
 
 
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -75,6 +78,7 @@ func (s *DockerSuite) TestStatsAllRunningNoStream(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestStatsAllNoStream(c *check.C) {
 func (s *DockerSuite) TestStatsAllNoStream(c *check.C) {
+	// Windows does not support stats
 	testRequires(c, DaemonIsLinux)
 	testRequires(c, DaemonIsLinux)
 
 
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
 	out, _ := dockerCmd(c, "run", "-d", "busybox", "top")
@@ -92,6 +96,7 @@ func (s *DockerSuite) TestStatsAllNoStream(c *check.C) {
 }
 }
 
 
 func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) {
 func (s *DockerSuite) TestStatsAllNewContainersAdded(c *check.C) {
+	// Windows does not support stats
 	testRequires(c, DaemonIsLinux)
 	testRequires(c, DaemonIsLinux)
 
 
 	id := make(chan string)
 	id := make(chan string)