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

Add logging in case we have minimum memory recommendations #299

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
21 changes: 21 additions & 0 deletions vertical-pod-autoscaler/pkg/recommender/logic/estimator.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ limitations under the License.
package logic

import (
"encoding/json"
"k8s.io/klog/v2"
"math"
"time"

Expand Down Expand Up @@ -152,9 +154,28 @@ func (e *minResourcesEstimator) GetResourceEstimation(s *model.AggregateContaine
newResources := make(model.Resources)
for resource, resourceAmount := range originalResources {
if resourceAmount < e.minResources[resource] {
klog.Warningf("Computed resources for %s were below minimum! Computed %v, minimum is %v.", resource, resourceAmount, e.minResources[resource])
resourceAmount = e.minResources[resource]
logHistogramInformation(s)
}
newResources[resource] = resourceAmount
}
return newResources
}

func logHistogramInformation(s *model.AggregateContainerState) {
if s.AggregateCPUUsage == nil {
klog.Warning("Aggregate CPU usage has no metric samples, cannot show internal histogram data!")
return
}
if s.AggregateMemoryPeaks == nil {
klog.Warning("Aggregate memory usage has no metric samples, cannot show internal histogram data!")
return
}
c, _ := s.SaveToCheckpoint()
prettyCheckpoint, err := json.MarshalIndent(c, "", " ")
if err != nil {
klog.Errorf("Error during marshalling checkpoint: %s", err)
}
klog.Warningf("Here's the checkpoint/state: %s", prettyCheckpoint)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need a line break before the checkpoint content?

}
Loading