@@ -20,6 +20,7 @@ import (
2020 "context"
2121 "errors"
2222 "fmt"
23+ "slices"
2324 "sync"
2425
2526 "go.uber.org/zap"
@@ -233,15 +234,22 @@ func (r *Reconciler) reconcile(ctx context.Context, log *zap.SugaredLogger, vwUR
233234 }
234235
235236 // find all PublishedResources
236- pubResources := & syncagentv1alpha1.PublishedResourceList {}
237- if err := r .localManager .GetClient ().List (ctx , pubResources , & ctrlruntimeclient.ListOptions {
237+ pubResList := & syncagentv1alpha1.PublishedResourceList {}
238+ if err := r .localManager .GetClient ().List (ctx , pubResList , & ctrlruntimeclient.ListOptions {
238239 LabelSelector : r .prFilter ,
239240 }); err != nil {
240241 return fmt .Errorf ("failed to list PublishedResources: %w" , err )
241242 }
242243
244+ // Filter out those that have not been processed into APIResourceSchemas yet; starting
245+ // sync controllers too early, before the schemes are available, will make the watches
246+ // not work properly.
247+ pubResources := slices .DeleteFunc (pubResList .Items , func (pr syncagentv1alpha1.PublishedResource ) bool {
248+ return pr .Status .ResourceSchemaName == ""
249+ })
250+
243251 // make sure that for every PublishedResource, a matching sync controller exists
244- if err := r .ensureSyncControllers (ctx , log , pubResources . Items ); err != nil {
252+ if err := r .ensureSyncControllers (ctx , log , pubResources ); err != nil {
245253 return fmt .Errorf ("failed to ensure sync controllers: %w" , err )
246254 }
247255
0 commit comments