Skip to content

Commit

Permalink
Skip upsynced resources in resource controller
Browse files Browse the repository at this point in the history
Signed-off-by: David Festal <dfestal@redhat.com>
  • Loading branch information
davidfestal committed Jan 5, 2023
1 parent c14bdee commit 73b6c1d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions pkg/reconciler/workload/resource/resource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,16 @@ func (c *Controller) enqueueSyncTargetKey(syncTargetKey string) {
}
}

// isUpSynced
func isUpSynced(labels map[string]string) bool {
for k, v := range labels {
if strings.HasPrefix(k, workloadv1alpha1.ClusterResourceStateLabelPrefix) && v == string(workloadv1alpha1.ResourceStateUpsync) {
return true
}
}
return false
}

// getLocations returns a set with of all the locations extracted from a resource labels, setting skipPending to true will ignore resources in not Sync state.
func getLocations(labels map[string]string, skipPending bool) sets.String {
locations := sets.NewString()
Expand Down
5 changes: 5 additions & 0 deletions pkg/reconciler/workload/resource/resource_reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ func (c *Controller) reconcileResource(ctx context.Context, lclusterName logical
logger := logging.WithObject(logging.WithReconciler(klog.Background(), ControllerName), obj).WithValues("groupVersionResource", gvr.String(), "logicalCluster", lclusterName.String())
logger.V(4).Info("reconciling resource")

if isUpSynced(obj.GetLabels()) {
logger.Info("resource is a Upsynced; ignoring")
return nil
}

// if the resource is a namespace, let's return early. nothing to do.
namespaceGVR := &schema.GroupVersionResource{Group: "", Version: "v1", Resource: "namespaces"}
if gvr == namespaceGVR {
Expand Down

0 comments on commit 73b6c1d

Please sign in to comment.