diff --git a/vertical-pod-autoscaler/pkg/recommender/model/container.go b/vertical-pod-autoscaler/pkg/recommender/model/container.go index 7c1e91d5a8b7..035a441e0a42 100644 --- a/vertical-pod-autoscaler/pkg/recommender/model/container.go +++ b/vertical-pod-autoscaler/pkg/recommender/model/container.go @@ -25,13 +25,6 @@ import ( "k8s.io/klog/v2" ) -const ( - // OOMBumpUpRatio specifies how much memory will be added after observing OOM. - OOMBumpUpRatio float64 = 1.2 - // OOMMinBumpUp specifies minimal increase of memory after observing OOM. - OOMMinBumpUp float64 = 100 * 1024 * 1024 // 100MB -) - // ContainerUsageSample is a measure of resource usage of a container over some // interval. type ContainerUsageSample struct { @@ -166,7 +159,7 @@ func (container *ContainerState) addMemorySample(sample *ContainerUsageSample, i } else { // Shift the memory aggregation window to the next interval. memoryAggregationInterval := GetAggregationsConfig().MemoryAggregationInterval - shift := truncate(ts.Sub(container.WindowEnd), memoryAggregationInterval) + memoryAggregationInterval + shift := ts.Sub(container.WindowEnd).Truncate(memoryAggregationInterval) + memoryAggregationInterval container.WindowEnd = container.WindowEnd.Add(shift) container.memoryPeak = 0 container.oomPeak = 0 @@ -230,14 +223,3 @@ func (container *ContainerState) AddSample(sample *ContainerUsageSample) bool { return false } } - -// Truncate returns the result of rounding d toward zero to a multiple of m. -// If m <= 0, Truncate returns d unchanged. -// This helper function is introduced to support older implementations of the -// time package that don't provide Duration.Truncate function. -func truncate(d, m time.Duration) time.Duration { - if m <= 0 { - return d - } - return d - d%m -}