Report
When the metrics-api scaler aggregates metrics from multiple Kubernetes service endpoints with aggregationType: average (the default), and every endpoint request fails, aggregateMetricsFromMultipleEndpoints still divides the aggregated value by expectedNbMetrics after it has been decremented to 0.
|
if s.metadata.AggregationType == AverageAggregationType { |
|
aggregation /= float64(expectedNbMetrics) |
Expected Behavior
When no endpoint returns a successful metric:
- The scaler should not perform average division with a zero divisor.
- It should return a clear error (e.g. could not fetch from any endpoint).
- The reported metric value should remain finite (e.g.
0) and must not be +Inf / NaN.
Actual Behavior
When all parallel endpoint fetches fail:
- Each failure decrements
expectedNbMetrics.
expectedNbMetrics reaches 0.
- The code still runs
aggregation /= float64(expectedNbMetrics) for aggregationType: average.
- The function can return
+Inf (or NaN) as the metric value.
Steps to Reproduce the Problem
.
Logs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
None
Platform
None
Scaler Details
metrics_api_scaler
Would you be open to contributing a fix?
Yes
Anything else?
No response
Report
When the metrics-api scaler aggregates metrics from multiple Kubernetes service endpoints with
aggregationType: average(the default), and every endpoint request fails,aggregateMetricsFromMultipleEndpointsstill divides the aggregated value byexpectedNbMetricsafter it has been decremented to 0.keda/pkg/scalers/metrics_api_scaler.go
Lines 457 to 458 in ef9df93
Expected Behavior
When no endpoint returns a successful metric:
0) and must not be+Inf/NaN.Actual Behavior
When all parallel endpoint fetches fail:
expectedNbMetrics.expectedNbMetricsreaches0.aggregation /= float64(expectedNbMetrics)foraggregationType: average.+Inf(orNaN) as the metric value.Steps to Reproduce the Problem
.
Logs from KEDA operator
KEDA Version
2.19.0
Kubernetes Version
None
Platform
None
Scaler Details
metrics_api_scaler
Would you be open to contributing a fix?
Yes
Anything else?
No response