diff --git a/pkg/controllers/execution/execution_controller.go b/pkg/controllers/execution/execution_controller.go index 5e6bef76e..600898871 100644 --- a/pkg/controllers/execution/execution_controller.go +++ b/pkg/controllers/execution/execution_controller.go @@ -271,10 +271,18 @@ func (c *Controller) updateAppliedCondition(work *workv1alpha1.Work, status meta } return retry.RetryOnConflict(retry.DefaultRetry, func() (err error) { - if err = c.Get(context.TODO(), client.ObjectKey{Namespace: work.Namespace, Name: work.Name}, work); err != nil { - return err - } meta.SetStatusCondition(&work.Status.Conditions, newWorkAppliedCondition) - return c.Status().Update(context.TODO(), work) + updateErr := c.Status().Update(context.TODO(), work) + if updateErr == nil { + return nil + } + updated := &workv1alpha1.Work{} + if err = c.Get(context.TODO(), client.ObjectKey{Namespace: work.Namespace, Name: work.Name}, updated); err == nil { + // make a copy, so we don't mutate the shared cache + work = updated.DeepCopy() + } else { + klog.Errorf("failed to get updated work %s/%s: %v", work.Namespace, work.Name, err) + } + return updateErr }) }