Skip to content

Commit

Permalink
Merge pull request #299 from voelzmo/enh/add-logging-for-minimum-reco…
Browse files Browse the repository at this point in the history
…mmendations

Add logging in case we have minimum memory recommendations
  • Loading branch information
voelzmo authored Mar 11, 2024
2 parents 3179ae7 + b82c8d2 commit f838d65
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 f838d65

Please sign in to comment.