Skip to content

Commit

Permalink
start informers after the listers have been requested
Browse files Browse the repository at this point in the history
  • Loading branch information
deads2k authored and openshift-cherrypick-robot committed Jun 3, 2019
1 parent 05b01f6 commit 5dbeda5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/operator/staticpod/certsyncpod/certsync_cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ func (o *CertSyncControllerOptions) Run() error {
observer.AddReactor(fileobserver.ExitOnChangeReactor, map[string][]byte{o.KubeConfigFile: initialContent}, o.KubeConfigFile)

stopCh := make(chan struct{})
go observer.Run(stopCh)

kubeInformers := informers.NewSharedInformerFactoryWithOptions(o.kubeClient, 10*time.Minute, informers.WithNamespace(o.Namespace))
go kubeInformers.Start(stopCh)

eventRecorder := events.NewKubeRecorder(o.kubeClient.CoreV1().Events(o.Namespace), "cert-syncer",
&corev1.ObjectReference{
Expand All @@ -90,7 +88,11 @@ func (o *CertSyncControllerOptions) Run() error {
if err != nil {
return err
}

// start everything. Informers start after they have been requested.
go controller.Run(1, stopCh)
go observer.Run(stopCh)
go kubeInformers.Start(stopCh)

<-stopCh
klog.Infof("Shutting down certificate syncer")
Expand Down
6 changes: 6 additions & 0 deletions pkg/operator/staticpod/certsyncpod/certsync_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ func (c *CertSyncController) Run(workers int, stopCh <-chan struct{}) {
klog.Infof("Starting CertSyncer")
defer klog.Infof("Shutting down CertSyncer")

if !cache.WaitForCacheSync(stopCh, c.preRunCaches...) {
klog.Error("failed waiting for caches")
return
}
klog.V(2).Infof("CertSyncer caches synced")

// doesn't matter what workers say, only start one.
go wait.Until(c.runWorker, time.Second, stopCh)

Expand Down

0 comments on commit 5dbeda5

Please sign in to comment.