Skip to content

Commit

Permalink
copy metric specs from horizontalPodAutoscalerConfig to HPA
Browse files Browse the repository at this point in the history
  • Loading branch information
imroc committed May 17, 2024
1 parent 40c532a commit d8567da
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion controllers/keda/hpa.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ func (r *ScaledObjectReconciler) newHPAForScaledObject(ctx context.Context, logg

var behavior *autoscalingv2.HorizontalPodAutoscalerBehavior
if scaledObject.Spec.Advanced != nil && scaledObject.Spec.Advanced.HorizontalPodAutoscalerConfig != nil {
behavior = scaledObject.Spec.Advanced.HorizontalPodAutoscalerConfig.Behavior
hpaConfig := scaledObject.Spec.Advanced.HorizontalPodAutoscalerConfig
behavior = hpaConfig.Behavior
for _, metricSpec := range hpaConfig.Metrics {
if metricSpec.Type == autoscalingv2.ExternalMetricSourceType { // external metrics is not allowed, cuz it is used by KEDA.
return nil, fmt.Errorf("external type is not allowed in horizontalPodAutoscalerConfig.metrics")
}
scaledObjectMetricSpecs = append(scaledObjectMetricSpecs, metricSpec)
}
} else {
behavior = nil
}
Expand Down

0 comments on commit d8567da

Please sign in to comment.