Rework hostfs metrics

Ephemeral storage usage should be calculated by the metrics code,
not the eviction code.
This commit is contained in:
Derek Carr
2020-06-12 16:42:36 -04:00
committed by Joel Smith
parent 39a11744ce
commit acb43c7c4a
13 changed files with 319 additions and 209 deletions

View File

@@ -351,7 +351,7 @@ func uint64Ptr(i uint64) *uint64 {
}
func calcEphemeralStorage(containers []statsapi.ContainerStats, volumes []statsapi.VolumeStats, rootFsInfo *cadvisorapiv2.FsInfo,
podLogStats *statsapi.FsStats, isCRIStatsProvider bool) *statsapi.FsStats {
podLogStats *statsapi.FsStats, etcHostsStats *statsapi.FsStats, isCRIStatsProvider bool) *statsapi.FsStats {
result := &statsapi.FsStats{
Time: metav1.NewTime(rootFsInfo.Timestamp),
AvailableBytes: &rootFsInfo.Available,
@@ -372,6 +372,11 @@ func calcEphemeralStorage(containers []statsapi.ContainerStats, volumes []statsa
result.InodesUsed = addUsage(result.InodesUsed, podLogStats.InodesUsed)
result.Time = maxUpdateTime(&result.Time, &podLogStats.Time)
}
if etcHostsStats != nil {
result.UsedBytes = addUsage(result.UsedBytes, etcHostsStats.UsedBytes)
result.InodesUsed = addUsage(result.InodesUsed, etcHostsStats.InodesUsed)
result.Time = maxUpdateTime(&result.Time, &etcHostsStats.Time)
}
return result
}