Merge pull request #4814 from whitewindmills/retry-on-conflict-for-apply-cluster-policy
Use RetryOnConflict for applying CRB
This commit is contained in:
commit
7a65ee8e11
|
@ -620,6 +620,7 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
bindingCopy := binding.DeepCopy()
|
bindingCopy := binding.DeepCopy()
|
||||||
|
err = retry.RetryOnConflict(retry.DefaultRetry, func() (err error) {
|
||||||
operationResult, err = controllerutil.CreateOrUpdate(context.TODO(), d.Client, bindingCopy, func() error {
|
operationResult, err = controllerutil.CreateOrUpdate(context.TODO(), d.Client, bindingCopy, func() error {
|
||||||
// If this binding exists and its owner is not the input object, return error and let garbage collector
|
// If this binding exists and its owner is not the input object, return error and let garbage collector
|
||||||
// delete this binding and try again later. See https://github.com/karmada-io/karmada/issues/2090.
|
// delete this binding and try again later. See https://github.com/karmada-io/karmada/issues/2090.
|
||||||
|
@ -646,6 +647,8 @@ func (d *ResourceDetector) ApplyClusterPolicy(object *unstructured.Unstructured,
|
||||||
bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution
|
bindingCopy.Spec.ConflictResolution = binding.Spec.ConflictResolution
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
return err
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
klog.Errorf("Failed to apply cluster policy(%s) for object: %s. error: %v", policy.Name, objectKey, err)
|
klog.Errorf("Failed to apply cluster policy(%s) for object: %s. error: %v", policy.Name, objectKey, err)
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue