ignore sample if it leads cpu utilization < 0
This commit is contained in:
parent
478ff3d45e
commit
0d85d23a89
@ -203,6 +203,10 @@ func NewSample(prev, current *ContainerStats) (*ContainerStatsSample, error) {
|
||||
if !current.Timestamp.After(prev.Timestamp) {
|
||||
return nil, fmt.Errorf("wrong stats order")
|
||||
}
|
||||
// This data is invalid.
|
||||
if current.Cpu.Usage.Total < prev.Cpu.Usage.Total {
|
||||
return nil, fmt.Errorf("current CPU usage is less than prev CPU usage (cumulative).")
|
||||
}
|
||||
sample := new(ContainerStatsSample)
|
||||
// Caculate the diff to get the CPU usage within the time interval.
|
||||
sample.Cpu.Usage = current.Cpu.Usage.Total - prev.Cpu.Usage.Total
|
||||
|
Loading…
Reference in New Issue
Block a user