Adding 'HasDiskIo' to Container Spec to indicate if diskio stats are available for a given container.

This commit is contained in:
Vishnu Kannan 2015-01-20 04:37:11 +00:00
parent 82bd9e927e
commit aedf42ba8c
4 changed files with 11 additions and 0 deletions

View File

@ -229,6 +229,8 @@ func libcontainerConfigToContainerSpec(config *libcontainer.Config, mi *info.Mac
}
spec.HasNetwork = true
spec.HasDiskIo = true
return spec
}

View File

@ -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 {

View File

@ -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

View File

@ -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.