Always collect disk stats for rootfs.
Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
parent
511ec9ef82
commit
2522da0ac5
@ -27,7 +27,7 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
||||
|
||||
if cHints.AllHosts[0].NetworkInterface.VethHost != "veth24031eth1" &&
|
||||
cHints.AllHosts[0].NetworkInterface.VethChild != "eth1" {
|
||||
t.Errorf("Cannot find network interface in %s", cHints)
|
||||
t.Errorf("Cannot find network interface in %+v", cHints)
|
||||
}
|
||||
|
||||
correctMountDirs := [...]string{
|
||||
@ -44,7 +44,7 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
||||
|
||||
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
||||
if correctMountDirs[i] != mountDir.HostDir {
|
||||
t.Errorf("Cannot find mount %s in %s", mountDir.HostDir, cHints)
|
||||
t.Errorf("Cannot find mount %s in %+v", mountDir.HostDir, cHints)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -188,8 +188,6 @@ func fsToFsStats(fs *fs.Fs) info.FsStats {
|
||||
|
||||
func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||
var filesystems []fs.Fs
|
||||
|
||||
if self.includedMetrics.Has(container.DiskUsageMetrics) || self.includedMetrics.Has(container.DiskIOMetrics) {
|
||||
var err error
|
||||
// Get Filesystem information only for the root cgroup.
|
||||
if isRootCgroup(self.name) {
|
||||
@ -197,7 +195,8 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if len(self.externalMounts) > 0 {
|
||||
} else if self.includedMetrics.Has(container.DiskUsageMetrics) || self.includedMetrics.Has(container.DiskIOMetrics) {
|
||||
if len(self.externalMounts) > 0 {
|
||||
var mountSet map[string]struct{}
|
||||
mountSet = make(map[string]struct{})
|
||||
for _, mount := range self.externalMounts {
|
||||
@ -210,14 +209,14 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||
}
|
||||
}
|
||||
|
||||
if self.includedMetrics.Has(container.DiskUsageMetrics) {
|
||||
if isRootCgroup(self.name) || self.includedMetrics.Has(container.DiskUsageMetrics) {
|
||||
for i := range filesystems {
|
||||
fs := filesystems[i]
|
||||
stats.Filesystem = append(stats.Filesystem, fsToFsStats(&fs))
|
||||
}
|
||||
}
|
||||
|
||||
if self.includedMetrics.Has(container.DiskIOMetrics) {
|
||||
if isRootCgroup(self.name) || self.includedMetrics.Has(container.DiskIOMetrics) {
|
||||
common.AssignDeviceNamesToDiskStats(&fsNamer{fs: filesystems, factory: self.machineInfoFactory}, &stats.DiskIo)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user