@@ -207,10 +207,10 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
207
207
ogQueueSet : queueinformer .NewEmptyResourceQueueSet (),
208
208
catalogSubscriberIndexer : map [string ]cache.Indexer {},
209
209
serviceAccountQuerier : scoped .NewUserDefinedServiceAccountQuerier (logger , crClient ),
210
- clientAttenuator : scoped .NewClientAttenuator (logger , config , opClient ),
210
+ clientAttenuator : scoped .NewClientAttenuator (logger , validatingConfig , opClient ),
211
211
installPlanTimeout : installPlanTimeout ,
212
212
bundleUnpackTimeout : bundleUnpackTimeout ,
213
- clientFactory : clients .NewFactory (config ),
213
+ clientFactory : clients .NewFactory (validatingConfig ),
214
214
}
215
215
op .sources = grpc .NewSourceStore (logger , 10 * time .Second , 10 * time .Minute , op .syncSourceState )
216
216
op .sourceInvalidator = resolver .SourceProviderFromRegistryClientProvider (op .sources , logger )
@@ -380,10 +380,22 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
380
380
op .lister .RbacV1 ().RegisterRoleLister (metav1 .NamespaceAll , roleInformer .Lister ())
381
381
sharedIndexInformers = append (sharedIndexInformers , roleInformer .Informer ())
382
382
383
- labelObjects := func (gvr schema.GroupVersionResource , informer cache.SharedIndexInformer , sync queueinformer.LegacySyncHandler ) error {
383
+ complete := map [schema.GroupVersionResource ][]bool {}
384
+ completeLock := & sync.Mutex {}
385
+
386
+ labelObjects := func (gvr schema.GroupVersionResource , informer cache.SharedIndexInformer , sync func (done func () bool ) queueinformer.LegacySyncHandler ) error {
384
387
if canFilter {
385
388
return nil
386
389
}
390
+ var idx int
391
+ if _ , exists := complete [gvr ]; exists {
392
+ idx = len (complete [gvr ])
393
+ complete [gvr ] = append (complete [gvr ], false )
394
+ } else {
395
+ idx = 0
396
+ complete [gvr ] = []bool {false }
397
+ }
398
+
387
399
queue := workqueue .NewRateLimitingQueueWithConfig (workqueue .DefaultControllerRateLimiter (), workqueue.RateLimitingQueueConfig {
388
400
Name : gvr .String (),
389
401
})
@@ -392,7 +404,18 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
392
404
queueinformer .WithQueue (queue ),
393
405
queueinformer .WithLogger (op .logger ),
394
406
queueinformer .WithInformer (informer ),
395
- queueinformer .WithSyncer (sync .ToSyncer ()),
407
+ queueinformer .WithSyncer (sync (func () bool {
408
+ completeLock .Lock ()
409
+ complete [gvr ][idx ] = true
410
+ allDone := true
411
+ for _ , items := range complete {
412
+ for _ , done := range items {
413
+ allDone = allDone && done
414
+ }
415
+ }
416
+ completeLock .Unlock ()
417
+ return allDone
418
+ }).ToSyncer ()),
396
419
)
397
420
if err != nil {
398
421
return err
@@ -408,6 +431,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
408
431
rolesgvk := rbacv1 .SchemeGroupVersion .WithResource ("roles" )
409
432
if err := labelObjects (rolesgvk , roleInformer .Informer (), labeller .ObjectLabeler [* rbacv1.Role , * rbacv1applyconfigurations.RoleApplyConfiguration ](
410
433
ctx , op .logger , labeller .Filter (rolesgvk ),
434
+ roleInformer .Lister ().List ,
411
435
rbacv1applyconfigurations .Role ,
412
436
func (namespace string , ctx context.Context , cfg * rbacv1applyconfigurations.RoleApplyConfiguration , opts metav1.ApplyOptions ) (* rbacv1.Role , error ) {
413
437
return op .opClient .KubernetesInterface ().RbacV1 ().Roles (namespace ).Apply (ctx , cfg , opts )
@@ -420,6 +444,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
420
444
func (role * rbacv1.Role ) (string , error ) {
421
445
return resolver .PolicyRuleHashLabelValue (role .Rules )
422
446
},
447
+ roleInformer .Lister ().List ,
423
448
rbacv1applyconfigurations .Role ,
424
449
func (namespace string , ctx context.Context , cfg * rbacv1applyconfigurations.RoleApplyConfiguration , opts metav1.ApplyOptions ) (* rbacv1.Role , error ) {
425
450
return op .opClient .KubernetesInterface ().RbacV1 ().Roles (namespace ).Apply (ctx , cfg , opts )
@@ -436,6 +461,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
436
461
rolebindingsgvk := rbacv1 .SchemeGroupVersion .WithResource ("rolebindings" )
437
462
if err := labelObjects (rolebindingsgvk , roleBindingInformer .Informer (), labeller .ObjectLabeler [* rbacv1.RoleBinding , * rbacv1applyconfigurations.RoleBindingApplyConfiguration ](
438
463
ctx , op .logger , labeller .Filter (rolebindingsgvk ),
464
+ roleBindingInformer .Lister ().List ,
439
465
rbacv1applyconfigurations .RoleBinding ,
440
466
func (namespace string , ctx context.Context , cfg * rbacv1applyconfigurations.RoleBindingApplyConfiguration , opts metav1.ApplyOptions ) (* rbacv1.RoleBinding , error ) {
441
467
return op .opClient .KubernetesInterface ().RbacV1 ().RoleBindings (namespace ).Apply (ctx , cfg , opts )
@@ -448,6 +474,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
448
474
func (roleBinding * rbacv1.RoleBinding ) (string , error ) {
449
475
return resolver .RoleReferenceAndSubjectHashLabelValue (roleBinding .RoleRef , roleBinding .Subjects )
450
476
},
477
+ roleBindingInformer .Lister ().List ,
451
478
rbacv1applyconfigurations .RoleBinding ,
452
479
func (namespace string , ctx context.Context , cfg * rbacv1applyconfigurations.RoleBindingApplyConfiguration , opts metav1.ApplyOptions ) (* rbacv1.RoleBinding , error ) {
453
480
return op .opClient .KubernetesInterface ().RbacV1 ().RoleBindings (namespace ).Apply (ctx , cfg , opts )
@@ -464,6 +491,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
464
491
serviceaccountsgvk := corev1 .SchemeGroupVersion .WithResource ("serviceaccounts" )
465
492
if err := labelObjects (serviceaccountsgvk , serviceAccountInformer .Informer (), labeller .ObjectLabeler [* corev1.ServiceAccount , * corev1applyconfigurations.ServiceAccountApplyConfiguration ](
466
493
ctx , op .logger , labeller .Filter (serviceaccountsgvk ),
494
+ serviceAccountInformer .Lister ().List ,
467
495
corev1applyconfigurations .ServiceAccount ,
468
496
func (namespace string , ctx context.Context , cfg * corev1applyconfigurations.ServiceAccountApplyConfiguration , opts metav1.ApplyOptions ) (* corev1.ServiceAccount , error ) {
469
497
return op .opClient .KubernetesInterface ().CoreV1 ().ServiceAccounts (namespace ).Apply (ctx , cfg , opts )
@@ -480,6 +508,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
480
508
servicesgvk := corev1 .SchemeGroupVersion .WithResource ("services" )
481
509
if err := labelObjects (servicesgvk , serviceInformer .Informer (), labeller .ObjectLabeler [* corev1.Service , * corev1applyconfigurations.ServiceApplyConfiguration ](
482
510
ctx , op .logger , labeller .Filter (servicesgvk ),
511
+ serviceInformer .Lister ().List ,
483
512
corev1applyconfigurations .Service ,
484
513
func (namespace string , ctx context.Context , cfg * corev1applyconfigurations.ServiceApplyConfiguration , opts metav1.ApplyOptions ) (* corev1.Service , error ) {
485
514
return op .opClient .KubernetesInterface ().CoreV1 ().Services (namespace ).Apply (ctx , cfg , opts )
@@ -505,6 +534,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
505
534
podsgvk := corev1 .SchemeGroupVersion .WithResource ("pods" )
506
535
if err := labelObjects (podsgvk , csPodInformer .Informer (), labeller .ObjectLabeler [* corev1.Pod , * corev1applyconfigurations.PodApplyConfiguration ](
507
536
ctx , op .logger , labeller .Filter (podsgvk ),
537
+ csPodInformer .Lister ().List ,
508
538
corev1applyconfigurations .Pod ,
509
539
func (namespace string , ctx context.Context , cfg * corev1applyconfigurations.PodApplyConfiguration , opts metav1.ApplyOptions ) (* corev1.Pod , error ) {
510
540
return op .opClient .KubernetesInterface ().CoreV1 ().Pods (namespace ).Apply (ctx , cfg , opts )
@@ -542,6 +572,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
542
572
ctx , op .logger , labeller .JobFilter (func (namespace , name string ) (metav1.Object , error ) {
543
573
return configMapInformer .Lister ().ConfigMaps (namespace ).Get (name )
544
574
}),
575
+ jobInformer .Lister ().List ,
545
576
batchv1applyconfigurations .Job ,
546
577
func (namespace string , ctx context.Context , cfg * batchv1applyconfigurations.JobApplyConfiguration , opts metav1.ApplyOptions ) (* batchv1.Job , error ) {
547
578
return op .opClient .KubernetesInterface ().BatchV1 ().Jobs (namespace ).Apply (ctx , cfg , opts )
@@ -617,6 +648,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
617
648
customresourcedefinitionsgvk := apiextensionsv1 .SchemeGroupVersion .WithResource ("customresourcedefinitions" )
618
649
if err := labelObjects (customresourcedefinitionsgvk , crdInformer , labeller .ObjectPatchLabeler (
619
650
ctx , op .logger , labeller .Filter (customresourcedefinitionsgvk ),
651
+ crdLister .List ,
620
652
op .opClient .ApiextensionsInterface ().ApiextensionsV1 ().CustomResourceDefinitions ().Patch ,
621
653
)); err != nil {
622
654
return nil , err
0 commit comments