Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup recommender model/container.go #5575

Merged
merged 2 commits into from
Mar 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 1 addition & 19 deletions vertical-pod-autoscaler/pkg/recommender/model/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}