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" &&
|
if cHints.AllHosts[0].NetworkInterface.VethHost != "veth24031eth1" &&
|
||||||
cHints.AllHosts[0].NetworkInterface.VethChild != "eth1" {
|
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{
|
correctMountDirs := [...]string{
|
||||||
@ -44,7 +44,7 @@ func TestGetContainerHintsFromFile(t *testing.T) {
|
|||||||
|
|
||||||
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
for i, mountDir := range cHints.AllHosts[0].Mounts {
|
||||||
if correctMountDirs[i] != mountDir.HostDir {
|
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,16 +188,15 @@ func fsToFsStats(fs *fs.Fs) info.FsStats {
|
|||||||
|
|
||||||
func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||||
var filesystems []fs.Fs
|
var filesystems []fs.Fs
|
||||||
|
var err error
|
||||||
if self.includedMetrics.Has(container.DiskUsageMetrics) || self.includedMetrics.Has(container.DiskIOMetrics) {
|
// Get Filesystem information only for the root cgroup.
|
||||||
var err error
|
if isRootCgroup(self.name) {
|
||||||
// Get Filesystem information only for the root cgroup.
|
filesystems, err = self.fsInfo.GetGlobalFsInfo()
|
||||||
if isRootCgroup(self.name) {
|
if err != nil {
|
||||||
filesystems, err = self.fsInfo.GetGlobalFsInfo()
|
return err
|
||||||
if err != nil {
|
}
|
||||||
return err
|
} else if self.includedMetrics.Has(container.DiskUsageMetrics) || self.includedMetrics.Has(container.DiskIOMetrics) {
|
||||||
}
|
if len(self.externalMounts) > 0 {
|
||||||
} else if len(self.externalMounts) > 0 {
|
|
||||||
var mountSet map[string]struct{}
|
var mountSet map[string]struct{}
|
||||||
mountSet = make(map[string]struct{})
|
mountSet = make(map[string]struct{})
|
||||||
for _, mount := range self.externalMounts {
|
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 {
|
for i := range filesystems {
|
||||||
fs := filesystems[i]
|
fs := filesystems[i]
|
||||||
stats.Filesystem = append(stats.Filesystem, fsToFsStats(&fs))
|
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)
|
common.AssignDeviceNamesToDiskStats(&fsNamer{fs: filesystems, factory: self.machineInfoFactory}, &stats.DiskIo)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user