diff --git a/CHANGELOG.md b/CHANGELOG.md index e2c8a0ded92..faf473f4201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ - **General:** Improve e2e tests reliability ([#2580](https://github.com/kedacore/keda/issues/2580)) - **General:** Syncronize HPA annotations from ScaledObject ([#2659](https://github.com/kedacore/keda/pull/2659)) - **General:** Improve e2e tests to always cleanup resources in cluster ([#2584](https://github.com/kedacore/keda/issues/2584)) +- **General:** Fix mismatched errors for updating hpa ([#2719](https://github.com/kedacore/keda/issues/2719)) - **Memory Scaler** Adding e2e test for the memory scaler ([#2220](https://github.com/kedacore/keda/issues/2220)) ## v.2.6.1 diff --git a/controllers/keda/hpa.go b/controllers/keda/hpa.go index f5b1551164e..f2eb65c9828 100644 --- a/controllers/keda/hpa.go +++ b/controllers/keda/hpa.go @@ -131,7 +131,7 @@ func (r *ScaledObjectReconciler) updateHPAIfNeeded(ctx context.Context, logger l // 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(ctx, hpa) != nil { + if err = r.Client.Update(ctx, hpa); err != nil { foundHpa.Spec = hpa.Spec logger.Error(err, "Failed to update HPA", "HPA.Namespace", foundHpa.Namespace, "HPA.Name", foundHpa.Name) return err @@ -144,7 +144,7 @@ func (r *ScaledObjectReconciler) updateHPAIfNeeded(ctx context.Context, logger l if !equality.Semantic.DeepDerivative(hpa.ObjectMeta.Labels, foundHpa.ObjectMeta.Labels) { logger.V(1).Info("Found difference in the HPA labels accordint to ScaledObject", "currentHPA", foundHpa.ObjectMeta.Labels, "newHPA", hpa.ObjectMeta.Labels) - if r.Client.Update(ctx, hpa) != nil { + if err = r.Client.Update(ctx, hpa); err != nil { foundHpa.ObjectMeta.Labels = hpa.ObjectMeta.Labels logger.Error(err, "Failed to update HPA", "HPA.Namespace", foundHpa.Namespace, "HPA.Name", foundHpa.Name) return err