Cumulative stats can't decrease
During removal of the container a stat value might be reported as zero; in this case the caluclation could end up with an extremely large number. If the cumulative stat decreases report zero. Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
@@ -224,6 +224,11 @@ func (c *criService) getUsageNanoCores(containerID string, isSandbox bool, curre
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
// can't go backwards, this value might come in as 0 if the container was just removed
|
||||
if currentUsageCoreNanoSeconds < oldStats.UsageCoreNanoSeconds {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
newUsageNanoCores := uint64(float64(currentUsageCoreNanoSeconds-oldStats.UsageCoreNanoSeconds) /
|
||||
float64(nanoSeconds) * float64(time.Second/time.Nanosecond))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user