diff --git a/controllers/hpa.go b/controllers/hpa.go index 40c9a50741a..13b1d545e6f 100644 --- a/controllers/hpa.go +++ b/controllers/hpa.go @@ -111,7 +111,8 @@ func (r *ScaledObjectReconciler) updateHPAIfNeeded(logger logr.Logger, scaledObj return err } - if !equality.Semantic.DeepDerivative(hpa.Spec, foundHpa.Spec) { + // DeepDerivative ignores extra entries in arrays which makes removing the last trigger not update things, so trigger and update any time the metrics count is different. + if len(hpa.Spec.Metrics) != len(foundHpa.Spec.Metrics) || !equality.Semantic.DeepDerivative(hpa.Spec, foundHpa.Spec) { logger.V(1).Info("Found difference in the HPA spec accordint to ScaledObject", "currentHPA", foundHpa.Spec, "newHPA", hpa.Spec) if r.Client.Update(context.TODO(), hpa) != nil { foundHpa.Spec = hpa.Spec