Update first in RetryOnConflict
Signed-off-by: Rishi Kumar Ray <rishi.ray@knoldus.com>
This commit is contained in:
parent
3d7770332b
commit
893fbefa50
|
@ -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
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue