@@ -244,8 +244,9 @@ func (r *Reconciler) reconcile(ctx context.Context, log *zap.SugaredLogger, vwUR
244244 // Filter out those that have not been processed into APIResourceSchemas yet; starting
245245 // sync controllers too early, before the schemes are available, will make the watches
246246 // not work properly.
247+ // Also remove those PRs that have sync disabled.
247248 pubResources := slices .DeleteFunc (pubResList .Items , func (pr syncagentv1alpha1.PublishedResource ) bool {
248- return pr .Status .ResourceSchemaName == ""
249+ return pr .Status .ResourceSchemaName == "" || ! isSyncEnabled ( & pr )
249250 })
250251
251252 // make sure that for every PublishedResource, a matching sync controller exists
@@ -423,9 +424,7 @@ func isSyncEnabled(pr *syncagentv1alpha1.PublishedResource) bool {
423424func (r * Reconciler ) ensureSyncControllers (ctx context.Context , log * zap.SugaredLogger , publishedResources []syncagentv1alpha1.PublishedResource ) error {
424425 requiredWorkers := sets .New [string ]()
425426 for _ , pr := range publishedResources {
426- if isSyncEnabled (& pr ) {
427- requiredWorkers .Insert (getPublishedResourceKey (& pr ))
428- }
427+ requiredWorkers .Insert (getPublishedResourceKey (& pr ))
429428 }
430429
431430 // stop controllers that are no longer needed
@@ -445,10 +444,6 @@ func (r *Reconciler) ensureSyncControllers(ctx context.Context, log *zap.Sugared
445444
446445 // start missing controllers
447446 for _ , pubRes := range publishedResources {
448- if ! isSyncEnabled (& pubRes ) {
449- continue
450- }
451-
452447 key := getPublishedResourceKey (& pubRes )
453448
454449 // controller already exists
0 commit comments