mirror of https://github.com/k3s-io/k3s
Clean ineffectual assignments
Signed-off-by: ialidzhikov <i.alidjikov@gmail.com>k3s-v1.15.3
parent
baf4eb67ac
commit
c3b2fb0d11
|
@ -553,14 +553,14 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
|
||||||
currentReplicas := scale.Status.Replicas
|
currentReplicas := scale.Status.Replicas
|
||||||
a.recordInitialRecommendation(currentReplicas, key)
|
a.recordInitialRecommendation(currentReplicas, key)
|
||||||
|
|
||||||
var metricStatuses []autoscalingv2.MetricStatus
|
var (
|
||||||
metricDesiredReplicas := int32(0)
|
metricStatuses []autoscalingv2.MetricStatus
|
||||||
metricName := ""
|
metricDesiredReplicas int32
|
||||||
metricTimestamp := time.Time{}
|
metricName string
|
||||||
|
)
|
||||||
|
|
||||||
desiredReplicas := int32(0)
|
desiredReplicas := int32(0)
|
||||||
rescaleReason := ""
|
rescaleReason := ""
|
||||||
timestamp := time.Now()
|
|
||||||
|
|
||||||
rescale := true
|
rescale := true
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
|
||||||
rescaleReason = "Current number of replicas must be greater than 0"
|
rescaleReason = "Current number of replicas must be greater than 0"
|
||||||
desiredReplicas = 1
|
desiredReplicas = 1
|
||||||
} else {
|
} else {
|
||||||
|
var metricTimestamp time.Time
|
||||||
metricDesiredReplicas, metricName, metricStatuses, metricTimestamp, err = a.computeReplicasForMetrics(hpa, scale, hpa.Spec.Metrics)
|
metricDesiredReplicas, metricName, metricStatuses, metricTimestamp, err = a.computeReplicasForMetrics(hpa, scale, hpa.Spec.Metrics)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
a.setCurrentReplicasInStatus(hpa, currentReplicas)
|
a.setCurrentReplicasInStatus(hpa, currentReplicas)
|
||||||
|
@ -590,12 +590,11 @@ func (a *HorizontalController) reconcileAutoscaler(hpav1Shared *autoscalingv1.Ho
|
||||||
return fmt.Errorf("failed to compute desired number of replicas based on listed metrics for %s: %v", reference, err)
|
return fmt.Errorf("failed to compute desired number of replicas based on listed metrics for %s: %v", reference, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.V(4).Infof("proposing %v desired replicas (based on %s from %s) for %s", metricDesiredReplicas, metricName, timestamp, reference)
|
klog.V(4).Infof("proposing %v desired replicas (based on %s from %s) for %s", metricDesiredReplicas, metricName, metricTimestamp, reference)
|
||||||
|
|
||||||
rescaleMetric := ""
|
rescaleMetric := ""
|
||||||
if metricDesiredReplicas > desiredReplicas {
|
if metricDesiredReplicas > desiredReplicas {
|
||||||
desiredReplicas = metricDesiredReplicas
|
desiredReplicas = metricDesiredReplicas
|
||||||
timestamp = metricTimestamp
|
|
||||||
rescaleMetric = metricName
|
rescaleMetric = metricName
|
||||||
}
|
}
|
||||||
if desiredReplicas > currentReplicas {
|
if desiredReplicas > currentReplicas {
|
||||||
|
|
Loading…
Reference in New Issue