@@ -18,6 +18,7 @@ package promote
1818
1919import (
2020 "context"
21+ "errors"
2122 "fmt"
2223 "os"
2324
@@ -447,12 +448,9 @@ func (o *CommandPromoteOption) promoteDeps(memberClusterFactory cmdutil.Factory,
447448 controlPlaneKubeClientSet := kubeclientset .NewForConfigOrDie (config )
448449 sharedFactory := informers .NewSharedInformerFactory (controlPlaneKubeClientSet , 0 )
449450 serviceLister := sharedFactory .Core ().V1 ().Services ().Lister ()
451+
450452 sharedFactory .Start (stopCh )
451453 sharedFactory .WaitForCacheSync (stopCh )
452- controlPlaneInformerManager .Start ()
453- if sync := controlPlaneInformerManager .WaitForCacheSync (); sync == nil {
454- return fmt .Errorf ("informer factory for cluster does not exist" )
455- }
456454
457455 defaultInterpreter := native .NewDefaultInterpreter ()
458456 thirdpartyInterpreter := thirdparty .NewConfigurableInterpreter ()
@@ -462,6 +460,11 @@ func (o *CommandPromoteOption) promoteDeps(memberClusterFactory cmdutil.Factory,
462460 return fmt .Errorf ("failed to create customized interpreter: %v" , err )
463461 }
464462
463+ controlPlaneInformerManager .Start ()
464+ if syncs := controlPlaneInformerManager .WaitForCacheSync (); len (syncs ) == 0 {
465+ return errors .New ("no informers registered in the informer factory" )
466+ }
467+
465468 // check if the resource interpreter supports to interpret dependencies
466469 if ! defaultInterpreter .HookEnabled (obj .GroupVersionKind (), configv1alpha1 .InterpreterOperationInterpretDependency ) &&
467470 ! thirdpartyInterpreter .HookEnabled (obj .GroupVersionKind (), configv1alpha1 .InterpreterOperationInterpretDependency ) &&
0 commit comments