Merge pull request #133741 from kincoy/hpa-cleanup-redundant-casts

cleanup: remove redundant type conversions in podautoscaler
This commit is contained in:
Kubernetes Prow Robot 2025-09-01 04:35:20 -07:00 committed by GitHub
commit 1bcfd5cee7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 6 additions and 6 deletions

View file

@ -93,7 +93,7 @@ func statusOkWithOverrides(overrides ...autoscalingv2.HorizontalPodAutoscalerCon
resv1 := make([]autoscalingv2.HorizontalPodAutoscalerCondition, len(resv2))
for i, cond := range resv2 {
resv1[i] = autoscalingv2.HorizontalPodAutoscalerCondition{
Type: autoscalingv2.HorizontalPodAutoscalerConditionType(cond.Type),
Type: cond.Type,
Status: cond.Status,
Reason: cond.Reason,
}
@ -4003,7 +4003,7 @@ func TestCalculateScaleDownLimitWithBehaviors(t *testing.T) {
func generateScalingRules(pods, podsPeriod, percent, percentPeriod, stabilizationWindow int32) *autoscalingv2.HPAScalingRules {
policy := autoscalingv2.MaxChangePolicySelect
directionBehavior := autoscalingv2.HPAScalingRules{
StabilizationWindowSeconds: ptr.To(int32(stabilizationWindow)),
StabilizationWindowSeconds: ptr.To(stabilizationWindow),
SelectPolicy: &policy,
}
if pods != 0 {

View file

@ -159,7 +159,7 @@ func (c *customMetricsClient) GetRawMetric(metricName string, namespace string,
res[m.DescribedObject.Name] = PodMetric{
Timestamp: m.Timestamp.Time,
Window: window,
Value: int64(m.Value.MilliValue()),
Value: m.Value.MilliValue(),
}
}

View file

@ -241,7 +241,7 @@ func (tc *restClientTestCase) runTest(t *testing.T) {
isResource := len(tc.resourceName) > 0
isExternal := tc.metricSelector != nil
if isResource {
info, timestamp, err := metricsClient.GetResourceMetric(context.TODO(), v1.ResourceName(tc.resourceName), tc.namespace, tc.selector, tc.container)
info, timestamp, err := metricsClient.GetResourceMetric(context.TODO(), tc.resourceName, tc.namespace, tc.selector, tc.container)
tc.verifyResults(t, info, timestamp, err)
} else if isExternal {
tc.metricLabelSelector, err = metav1.LabelSelectorAsSelector(tc.metricSelector)

View file

@ -185,7 +185,7 @@ func (c *ReplicaCalculator) GetMetricReplicas(currentReplicas int32, targetUsage
return 0, 0, time.Time{}, fmt.Errorf("unable to get metric %s: %v", metricName, err)
}
replicaCount, usage, err = c.calcPlainMetricReplicas(metrics, currentReplicas, targetUsage, tolerances, namespace, selector, v1.ResourceName(""))
replicaCount, usage, err = c.calcPlainMetricReplicas(metrics, currentReplicas, targetUsage, tolerances, namespace, selector, "")
return replicaCount, usage, timestamp, err
}

View file

@ -287,7 +287,7 @@ func (tc *replicaCalcTestCase) prepareTestCMClient(t *testing.T) *cmfake.FakeCus
Metric: cmapi.MetricIdentifier{
Name: tc.metric.name,
},
Value: *resource.NewMilliQuantity(int64(tc.metric.levels[0]), resource.DecimalSI),
Value: *resource.NewMilliQuantity(tc.metric.levels[0], resource.DecimalSI),
},
}