@@ -41,6 +41,7 @@ import (
4141 "k8s.io/apimachinery/pkg/runtime"
4242 "k8s.io/apimachinery/pkg/types"
4343 "k8s.io/client-go/tools/record"
44+ "k8s.io/client-go/util/retry"
4445
4546 ctrl "sigs.k8s.io/controller-runtime"
4647 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -204,14 +205,18 @@ func (r *HermesInstanceReconciler) Reconcile(ctx context.Context, req ctrl.Reque
204205
205206 r .updateProfileStoreCondition (ctx , inst )
206207
207- // Snapshot status before final update to use Patch (avoids conflict with Flux SSA)
208- original := inst .DeepCopy ()
209- if err := r .updateStatus (ctx , inst ); err != nil {
210- logger .Error (err , "status update failed" )
211- } else {
212- if err := r .Status ().Patch (ctx , inst , client .MergeFrom (original )); err != nil {
213- logger .Error (err , "status patch failed" )
208+ // Retry status update on conflict (Flux SSA may modify the CR concurrently).
209+ statusErr := retry .RetryOnConflict (retry .DefaultRetry , func () error {
210+ if err := r .Get (ctx , types.NamespacedName {Name : inst .Name , Namespace : inst .Namespace }, inst ); err != nil {
211+ return err
214212 }
213+ if err := r .updateStatus (ctx , inst ); err != nil {
214+ return err
215+ }
216+ return r .Status ().Update (ctx , inst )
217+ })
218+ if statusErr != nil {
219+ logger .Error (statusErr , "status update failed" )
215220 }
216221
217222 return ctrl.Result {RequeueAfter : 5 * time .Minute }, nil
@@ -1140,7 +1145,7 @@ func (r *HermesInstanceReconciler) updateStatus(ctx context.Context, inst *herme
11401145 inst .Status .Phase = "Pending"
11411146 r .setCondition (inst , hermesv1 .ConditionTypeReady , metav1 .ConditionFalse , "StatefulSetNotReady" , "" )
11421147 }
1143- return nil // status computed, caller Patches
1148+ return r . Status (). Update ( ctx , inst )
11441149}
11451150
11461151// SetupWithManager wires watches for every owned type.
0 commit comments