Skip to content

Commit

Permalink
ClusterResourceSet: continue aplying when apply for a single cluster …
Browse files Browse the repository at this point in the history
…failed

Signed-off-by: Stefan Büringer buringerst@vmware.com
  • Loading branch information
sbueringer committed May 8, 2023
1 parent 7edbaf0 commit 506c570
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions exp/addons/internal/controllers/clusterresourceset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,18 +145,32 @@ func (r *ClusterResourceSetReconciler) Reconcile(ctx context.Context, req ctrl.R
return r.reconcileDelete(ctx, clusters, clusterResourceSet)
}

errs := []error{}
errClusterLockedOccurred := false
for _, cluster := range clusters {
if err := r.ApplyClusterResourceSet(ctx, cluster, clusterResourceSet); err != nil {
// Requeue if the reconcile failed because the ClusterCacheTracker was locked for
// the current cluster because of concurrent access.
if errors.Is(err, remote.ErrClusterLocked) {
log.V(5).Info("Requeuing because another worker has the lock on the ClusterCacheTracker")
return ctrl.Result{Requeue: true}, nil
errClusterLockedOccurred = true
} else {
// Append the error if the error is not ErrClusterLocked.
errs = append(errs, err)
}
return ctrl.Result{}, err
}
}

// Return an aggregated error if errors occurred.
if len(errs) > 0 {
return ctrl.Result{}, kerrors.NewAggregate(errs)
}

// Requeue if ErrClusterLocked was returned for one of the clusters.
if errClusterLockedOccurred {
return ctrl.Result{Requeue: true}, nil
}

return ctrl.Result{}, nil
}

Expand Down

0 comments on commit 506c570

Please sign in to comment.