Skip to content

Commit

Permalink
close scalers after name check
Browse files Browse the repository at this point in the history
Signed-off-by: ycabrer <[email protected]>
  • Loading branch information
ycabrer committed Mar 1, 2021
1 parent 69c0db3 commit f3ac4aa
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions controllers/scaledobject_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ func (r *ScaledObjectReconciler) reconcileScaledObject(logger logr.Logger, scale
return "ScaledObject doesn't have correct scaleTargetRef specification", err
}

// Check for any duplicate names in scaledObject
err = r.validateMetricNameUniqueness(logger, scaledObject)
if err != nil {
return "Error checking metric name uniqueness", err
Expand Down Expand Up @@ -260,6 +261,8 @@ func (r *ScaledObjectReconciler) validateMetricNameUniqueness(logger logr.Logger

observedMetricNames := make(map[string]struct{})
for _, scaler := range scalers {
defer scaler.Close()

for _, metric := range scaler.GetMetricSpecForScaling() {
// Only validate external metricNames
if metric.External == nil {
Expand Down

0 comments on commit f3ac4aa

Please sign in to comment.