Skip to content

Commit

Permalink
Add logging in case we have minimum memory recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
voelzmo committed Mar 8, 2024
1 parent 3179ae7 commit b82c8d2
Showing 1 changed file with 21 additions and 0 deletions.
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)
}

0 comments on commit b82c8d2

Please sign in to comment.