Skip to content

Commit

Permalink
informer: wait for cache sync before adding event handlers (#2768)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed May 8, 2023
1 parent a23dd86 commit d3d0176
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 144 deletions.
3 changes: 1 addition & 2 deletions cmd/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ func CmdMain() {
RetryPeriod: 6 * time.Second,
Callbacks: leaderelection.LeaderCallbacks{
OnStartedLeading: func(ctx context.Context) {
ctl := controller.NewController(config)
ctl.Run(ctx)
controller.Run(ctx, config)
},
OnStoppedLeading: func() {
select {
Expand Down
5 changes: 1 addition & 4 deletions cmd/daemon/cniserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,10 @@ func CmdMain() {
kubeovninformer.WithTweakListOptions(func(listOption *v1.ListOptions) {
listOption.AllowWatchBookmarks = true
}))
ctl, err := daemon.NewController(config, podInformerFactory, nodeInformerFactory, kubeovnInformerFactory)
ctl, err := daemon.NewController(config, stopCh, podInformerFactory, nodeInformerFactory, kubeovnInformerFactory)
if err != nil {
util.LogFatalAndExit(err, "failed to create controller")
}
podInformerFactory.Start(stopCh)
nodeInformerFactory.Start(stopCh)
kubeovnInformerFactory.Start(stopCh)
klog.Info("start daemon controller")
go ctl.Run(stopCh)
go daemon.RunServer(config, ctl)
Expand Down
Loading

0 comments on commit d3d0176

Please sign in to comment.