@@ -553,14 +553,14 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
553
553
currentReplicas := scale .Status .Replicas
554
554
a .recordInitialRecommendation (currentReplicas , key )
555
555
556
- var metricStatuses []autoscalingv2.MetricStatus
557
- metricDesiredReplicas := int32 (0 )
558
- metricName := ""
559
- metricTimestamp := time.Time {}
556
+ var (
557
+ metricStatuses []autoscalingv2.MetricStatus
558
+ metricDesiredReplicas int32
559
+ metricName string
560
+ )
560
561
561
562
desiredReplicas := int32 (0 )
562
563
rescaleReason := ""
563
- timestamp := time .Now ()
564
564
565
565
rescale := true
566
566
@@ -579,7 +579,7 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
579
579
rescaleReason = "Current number of replicas must be greater than 0"
580
580
desiredReplicas = 1
581
581
} else {
582
-
582
+ var metricTimestamp time. Time
583
583
metricDesiredReplicas , metricName , metricStatuses , metricTimestamp , err = a .computeReplicasForMetrics (hpa , scale , hpa .Spec .Metrics )
584
584
if err != nil {
585
585
a .setCurrentReplicasInStatus (hpa , currentReplicas )
@@ -590,12 +590,11 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
590
590
return fmt .Errorf ("failed to compute desired number of replicas based on listed metrics for %s: %v" , reference , err )
591
591
}
592
592
593
- klog .V (4 ).Infof ("proposing %v desired replicas (based on %s from %s) for %s" , metricDesiredReplicas , metricName , timestamp , reference )
593
+ klog .V (4 ).Infof ("proposing %v desired replicas (based on %s from %s) for %s" , metricDesiredReplicas , metricName , metricTimestamp , reference )
594
594
595
595
rescaleMetric := ""
596
596
if metricDesiredReplicas > desiredReplicas {
597
597
desiredReplicas = metricDesiredReplicas
598
- timestamp = metricTimestamp
599
598
rescaleMetric = metricName
600
599
}
601
600
if desiredReplicas > currentReplicas {
0 commit comments