diff --git a/CHANGELOG.md b/CHANGELOG.md index a1498ccf48f..1482554cf2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -90,8 +90,8 @@ New deprecation(s): ### Other -- TODO ([#XXX](https://github.com/kedacore/keda/issues/XXX)) - **General**: Added Pre Regex check before building image in e2e test ([#5783](https://github.com/kedacore/keda/issues/5783)) +- **General**: Reduce the number of ScaledObject.Status updates in the fallback ([#5624](https://github.com/kedacore/keda/issues/5624)) ## v2.14.0 diff --git a/pkg/fallback/fallback.go b/pkg/fallback/fallback.go index 59dac517519..967453cf4d5 100644 --- a/pkg/fallback/fallback.go +++ b/pkg/fallback/fallback.go @@ -18,6 +18,7 @@ package fallback import ( "context" + "reflect" "strconv" v2 "k8s.io/api/autoscaling/v2" @@ -137,10 +138,13 @@ func updateStatus(ctx context.Context, client runtimeclient.Client, scaledObject status.Conditions.SetFallbackCondition(metav1.ConditionFalse, "NoFallbackFound", "No fallbacks are active on this scaled object") } - scaledObject.Status = *status - err := client.Status().Patch(ctx, scaledObject, patch) - if err != nil { - log.Error(err, "failed to patch ScaledObjects Status", "scaledObject.Namespace", scaledObject.Namespace, "scaledObject.Name", scaledObject.Name) + // Update status only if it has changed + if !reflect.DeepEqual(scaledObject.Status, *status) { + scaledObject.Status = *status + err := client.Status().Patch(ctx, scaledObject, patch) + if err != nil { + log.Error(err, "failed to patch ScaledObjects Status", "scaledObject.Namespace", scaledObject.Namespace, "scaledObject.Name", scaledObject.Name) + } } }