From aedf42ba8c0dccd23c42c6fde6b9ec54b07d6129 Mon Sep 17 00:00:00 2001 From: Vishnu Kannan Date: Tue, 20 Jan 2015 04:37:11 +0000 Subject: [PATCH] Adding 'HasDiskIo' to Container Spec to indicate if diskio stats are available for a given container. --- container/docker/handler.go | 2 ++ container/raw/handler.go | 5 +++++ info/container.go | 3 +++ integration/tests/api/docker_test.go | 1 + 4 files changed, 11 insertions(+) diff --git a/container/docker/handler.go b/container/docker/handler.go index f09af734..2ad5778f 100644 --- a/container/docker/handler.go +++ b/container/docker/handler.go @@ -229,6 +229,8 @@ func libcontainerConfigToContainerSpec(config *libcontainer.Config, mi *info.Mac } spec.HasNetwork = true + spec.HasDiskIo = true + return spec } diff --git a/container/raw/handler.go b/container/raw/handler.go index 77ed73fe..408c8de5 100644 --- a/container/raw/handler.go +++ b/container/raw/handler.go @@ -225,6 +225,11 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) { //Network spec.HasNetwork = self.hasNetwork + // DiskIo. + if blkioRoot, ok := self.cgroupPaths["blkio"]; ok && utils.FileExists(blkioRoot) { + spec.HasDiskIo = true + } + // Check physical network devices for root container. nd, err := self.GetRootNetworkDevices() if err != nil { diff --git a/info/container.go b/info/container.go index da66b2ed..2088644b 100644 --- a/info/container.go +++ b/info/container.go @@ -49,6 +49,9 @@ type ContainerSpec struct { HasNetwork bool `json:"has_network"` HasFilesystem bool `json:"has_filesystem"` + + // HasDiskIo when true, indicates that DiskIo stats will be available. + HasDiskIo bool `json:"has_diskio"` } // Container reference contains enough information to uniquely identify a container diff --git a/integration/tests/api/docker_test.go b/integration/tests/api/docker_test.go index abb4b766..41fd3af7 100644 --- a/integration/tests/api/docker_test.go +++ b/integration/tests/api/docker_test.go @@ -199,6 +199,7 @@ func TestDockerContainerSpec(t *testing.T) { assert.Equal(containerInfo.Spec.Memory.Limit, memoryLimit, "Container should have memory limit of %d, has %d", memoryLimit, containerInfo.Spec.Memory.Limit) assert.True(containerInfo.Spec.HasNetwork, "Network should be isolated") assert.True(containerInfo.Spec.HasFilesystem, "Filesystem should be isolated") + assert.True(containerInfo.Spec.HasDiskIo, "Blkio should be isolated") } // Check the CPU ContainerStats.