@@ -21,9 +21,9 @@ import (
2121
2222 "k8s.io/autoscaler/cluster-autoscaler/simulator/clustersnapshot"
2323 "k8s.io/autoscaler/cluster-autoscaler/simulator/predicatechecker"
24+ "k8s.io/autoscaler/cluster-autoscaler/utils/klogx"
2425
2526 apiv1 "k8s.io/api/core/v1"
26- klog "k8s.io/klog/v2"
2727 schedulerframework "k8s.io/kubernetes/pkg/scheduler/framework"
2828)
2929
@@ -59,22 +59,23 @@ func (s *HintingSimulator) TrySchedulePods(clusterSnapshot clustersnapshot.Clust
5959 similarPods := NewSimilarPodsScheduling ()
6060
6161 var statuses []Status
62+ loggingQuota := klogx .PodsLoggingQuota ()
6263 for _ , pod := range pods {
63- klog .V (5 ).Infof ("Looking for place for %s/%s" , pod .Namespace , pod .Name )
64+ klogx .V (5 ). UpTo ( loggingQuota ).Infof ("Looking for place for %s/%s" , pod .Namespace , pod .Name )
6465 nodeName , err := s .findNodeWithHints (clusterSnapshot , pod , isNodeAcceptable )
6566 if err != nil {
6667 return nil , 0 , err
6768 }
6869
6970 if nodeName == "" {
70- nodeName , err = s .findNode (similarPods , clusterSnapshot , pod , isNodeAcceptable )
71+ nodeName , err = s .findNode (similarPods , clusterSnapshot , pod , loggingQuota , isNodeAcceptable )
7172 if err != nil {
7273 return nil , 0 , err
7374 }
7475 }
7576
7677 if nodeName != "" {
77- klog .V (4 ).Infof ("Pod %s/%s can be moved to %s" , pod .Namespace , pod .Name , nodeName )
78+ klogx .V (4 ). UpTo ( loggingQuota ).Infof ("Pod %s/%s can be moved to %s" , pod .Namespace , pod .Name , nodeName )
7879 if err := clusterSnapshot .AddPod (pod , nodeName ); err != nil {
7980 return nil , 0 , fmt .Errorf ("simulating scheduling of %s/%s to %s return error; %v" , pod .Namespace , pod .Name , nodeName , err )
8081 }
@@ -83,6 +84,7 @@ func (s *HintingSimulator) TrySchedulePods(clusterSnapshot clustersnapshot.Clust
8384 break
8485 }
8586 }
87+ klogx .V (4 ).Over (loggingQuota ).Infof ("There were also %v other logs from HintingSimulator.TrySchedulePods func that were capped." , - loggingQuota .Left ())
8688 return statuses , similarPods .OverflowingControllerCount (), nil
8789}
8890
@@ -105,15 +107,15 @@ func (s *HintingSimulator) findNodeWithHints(clusterSnapshot clustersnapshot.Clu
105107 return "" , nil
106108}
107109
108- func (s * HintingSimulator ) findNode (similarPods * SimilarPodsScheduling , clusterSnapshot clustersnapshot.ClusterSnapshot , pod * apiv1.Pod , isNodeAcceptable func (* schedulerframework.NodeInfo ) bool ) (string , error ) {
110+ func (s * HintingSimulator ) findNode (similarPods * SimilarPodsScheduling , clusterSnapshot clustersnapshot.ClusterSnapshot , pod * apiv1.Pod , loggingQuota * klogx. Quota , isNodeAcceptable func (* schedulerframework.NodeInfo ) bool ) (string , error ) {
109111 if similarPods .IsSimilarUnschedulable (pod ) {
110- klog .V (4 ).Infof ("failed to find place for %s/%s based on similar pods scheduling" , pod .Namespace , pod .Name )
112+ klogx .V (4 ). UpTo ( loggingQuota ).Infof ("failed to find place for %s/%s based on similar pods scheduling" , pod .Namespace , pod .Name )
111113 return "" , nil
112114 }
113115
114116 newNodeName , err := s .predicateChecker .FitsAnyNodeMatching (clusterSnapshot , pod , isNodeAcceptable )
115117 if err != nil {
116- klog .V (4 ).Infof ("failed to find place for %s/%s: %v" , pod .Namespace , pod .Name , err )
118+ klogx .V (4 ). UpTo ( loggingQuota ).Infof ("failed to find place for %s/%s: %v" , pod .Namespace , pod .Name , err )
117119 similarPods .SetUnschedulable (pod )
118120 return "" , nil
119121 }
0 commit comments