@@ -845,9 +845,11 @@ func (a *HorizontalController) reconcileAutoscaler(ctx context.Context, hpaShare
845
845
846
846
logger .V (4 ).Info ("Proposing desired replicas" ,
847
847
"desiredReplicas" , metricDesiredReplicas ,
848
+ "currentReplicas" , currentReplicas ,
848
849
"metric" , metricName ,
849
850
"timestamp" , metricTimestamp ,
850
- "scaleTarget" , reference )
851
+ "scaleTarget" , reference ,
852
+ "metrics" , metricStatuses )
851
853
852
854
rescaleMetric := ""
853
855
if metricDesiredReplicas > desiredReplicas {
@@ -885,6 +887,7 @@ func (a *HorizontalController) reconcileAutoscaler(ctx context.Context, hpaShare
885
887
a .storeScaleEvent (hpa .Spec .Behavior , key , currentReplicas , desiredReplicas )
886
888
logger .Info ("Successfully rescaled" ,
887
889
"HPA" , klog .KObj (hpa ),
890
+ "scaleTarget" , reference ,
888
891
"currentReplicas" , currentReplicas ,
889
892
"desiredReplicas" , desiredReplicas ,
890
893
"reason" , rescaleReason )
@@ -957,6 +960,9 @@ func (a *HorizontalController) normalizeDesiredReplicas(hpa *autoscalingv2.Horiz
957
960
} else {
958
961
setCondition (hpa , autoscalingv2 .ScalingLimited , v1 .ConditionTrue , reason , "%s" , message )
959
962
}
963
+ reference := fmt .Sprintf ("%s/%s/%s" , hpa .Spec .ScaleTargetRef .Kind , hpa .Namespace , hpa .Spec .ScaleTargetRef .Name )
964
+ klog .V (4 ).Infof ("Normalized desired replicas: scaleTarget=%s, currentReplicas=%d, desiredReplicas=%d, minReplicas=%d, stabilizedRecommendation=%d, prenormalizedDesiredReplicas=%d, condition=%s, reason=%s" ,
965
+ reference , currentReplicas , desiredReplicas , minReplicas , stabilizedRecommendation , prenormalizedDesiredReplicas , reason , reason )
960
966
961
967
return desiredReplicas
962
968
}
@@ -995,13 +1001,21 @@ func (a *HorizontalController) normalizeDesiredReplicasWithBehaviors(hpa *autosc
995
1001
} else {
996
1002
setCondition (hpa , autoscalingv2 .AbleToScale , v1 .ConditionTrue , "ReadyForNewScale" , "recommended size matches current size" )
997
1003
}
1004
+
1005
+ reference := fmt .Sprintf ("%s/%s/%s" , hpa .Spec .ScaleTargetRef .Kind , hpa .Namespace , hpa .Spec .ScaleTargetRef .Name )
1006
+ klog .V (4 ).Infof ("Normalized desired replicas with behaviors - after stabilized recommendation: scaleTarget=%s, currentReplicas=%d, minReplicas=%d, stabilizedRecommendation=%d, prenormalizedDesiredReplicas=%d, reason=%s, message=%s" ,
1007
+ reference , currentReplicas , minReplicas , stabilizedRecommendation , prenormalizedDesiredReplicas , reason , message )
1008
+
998
1009
desiredReplicas , reason , message := a .convertDesiredReplicasWithBehaviorRate (normalizationArg )
999
1010
if desiredReplicas == stabilizedRecommendation {
1000
1011
setCondition (hpa , autoscalingv2 .ScalingLimited , v1 .ConditionFalse , reason , "%s" , message )
1001
1012
} else {
1002
1013
setCondition (hpa , autoscalingv2 .ScalingLimited , v1 .ConditionTrue , reason , "%s" , message )
1003
1014
}
1004
1015
1016
+ klog .V (4 ).Infof ("Normalized desired replicas with behaviors - after rated recommendation: scaleTarget=%s, currentReplicas=%d, minReplicas=%d, stabilizedRecommendation=%d, desiredReplicas=%d, reason=%s, message=%s" ,
1017
+ reference , currentReplicas , minReplicas , stabilizedRecommendation , desiredReplicas , reason , message )
1018
+
1005
1019
return desiredReplicas
1006
1020
}
1007
1021
@@ -1128,7 +1142,13 @@ func (a *HorizontalController) stabilizeRecommendationWithBehaviors(args Normali
1128
1142
if recommendation > downRecommendation {
1129
1143
recommendation = downRecommendation
1130
1144
}
1131
-
1145
+ // Only keep the recommendations and ignore timestamp for logging.
1146
+ var recommendations []int32
1147
+ for _ , rec := range a .recommendations [args .Key ] {
1148
+ recommendations = append (recommendations , rec .recommendation )
1149
+ }
1150
+ klog .V (4 ).Infof ("Stabilizing recommendation: key=%s, currentReplicas=%d, desiredReplicas=%d, upRecommendation=%d, downRecommendation=%d, recommendations=%v" ,
1151
+ args .Key , args .CurrentReplicas , args .DesiredReplicas , upRecommendation , downRecommendation , recommendations )
1132
1152
// Record the unstabilized recommendation.
1133
1153
if foundOldSample {
1134
1154
a.recommendations [args.Key ][oldSampleIndex ] = timestampedRecommendation {args .DesiredReplicas , time .Now ()}
@@ -1158,6 +1178,8 @@ func (a *HorizontalController) convertDesiredReplicasWithBehaviorRate(args Norma
1158
1178
defer a .scaleUpEventsLock .RUnlock ()
1159
1179
a .scaleDownEventsLock .RLock ()
1160
1180
defer a .scaleDownEventsLock .RUnlock ()
1181
+ klog .V (4 ).Infof ("Converting desired replicas with behavior rate - scale up: key=%s, currentReplicas=%d, desiredReplicas=%d, scaleUpEvents=%v, scaleDownEvents=%v" ,
1182
+ args .Key , args .CurrentReplicas , args .DesiredReplicas , a .scaleUpEvents [args .Key ], a .scaleDownEvents [args .Key ])
1161
1183
scaleUpLimit := calculateScaleUpLimitWithScalingRules (args .CurrentReplicas , a .scaleUpEvents [args .Key ], a .scaleDownEvents [args .Key ], args .ScaleUpBehavior )
1162
1184
1163
1185
if scaleUpLimit < args .CurrentReplicas {
@@ -1181,6 +1203,8 @@ func (a *HorizontalController) convertDesiredReplicasWithBehaviorRate(args Norma
1181
1203
defer a .scaleUpEventsLock .RUnlock ()
1182
1204
a .scaleDownEventsLock .RLock ()
1183
1205
defer a .scaleDownEventsLock .RUnlock ()
1206
+ klog .V (4 ).Infof ("Converting desired replicas with behavior rate - scale down: key=%s, currentReplicas=%d, desiredReplicas=%d, scaleUpEvents=%v, scaleDownEvents=%v" ,
1207
+ args .Key , args .CurrentReplicas , args .DesiredReplicas , a .scaleUpEvents [args .Key ], a .scaleDownEvents [args .Key ])
1184
1208
scaleDownLimit := calculateScaleDownLimitWithBehaviors (args .CurrentReplicas , a .scaleUpEvents [args .Key ], a .scaleDownEvents [args .Key ], args .ScaleDownBehavior )
1185
1209
1186
1210
if scaleDownLimit > args .CurrentReplicas {
0 commit comments