Skip to content

Commit 0a9e613

Browse files
committed
CachedResource replication reconciler should retry on AlreadyExists
If the CachedObject is missing, and Create fails with AlreadyExists, the reconciler now returns an error and lets the work item to be requeued. The previous code would, in that case, attempt to do an Update but without setting the object's meta, the Update call would always fail (missing resourceVersion and others...). Letting the item to be requeued is cleaner and fixes object updates. On-behalf-of: @SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
1 parent f9221d7 commit 0a9e613

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

pkg/reconciler/cache/cachedresources/replication/replication_reconcile.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,7 @@ func (r *replicationReconciler) reconcile(ctx context.Context, gvr schema.GroupV
295295

296296
logger.V(2).Info("Creating object in global cache")
297297
_, err := r.createObject(ctx, clusterName, localCopy)
298-
if err != nil {
299-
if apierrors.IsAlreadyExists(err) {
300-
// If the object already exists, try to update it instead
301-
logger.V(2).Info("Object already exists in global cache, updating instead")
302-
_, err = r.updateObject(ctx, clusterName, localCopy)
303-
}
304-
if err != nil {
305-
return err
306-
}
307-
}
308-
return nil
298+
return err
309299
}
310300

311301
// update global copy and compare

0 commit comments

Comments
 (0)