Skip to content

Commit

Permalink
Start the grpc server after leader election
Browse files Browse the repository at this point in the history
  • Loading branch information
aledbf committed Aug 18, 2023
1 parent 7f968fa commit 5c7fa0b
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions components/ws-manager-mk2/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,19 @@ func main() {
os.Exit(1)
}

wsmanService, err := setupGRPCService(cfg, mgr.GetClient(), maintenanceReconciler)
if err != nil {
setupLog.Error(err, "unable to start manager service")
os.Exit(1)
}
// Wait for leader election to start the GRPC server
go func() {
<-mgr.Elected()

wsmanService, err := setupGRPCService(cfg, mgr.GetClient(), maintenanceReconciler)
if err != nil {
setupLog.Error(err, "unable to start manager service")
os.Exit(1)
}

workspaceReconciler.OnReconcile = wsmanService.OnWorkspaceReconcile
}()

workspaceReconciler.OnReconcile = wsmanService.OnWorkspaceReconcile
if err = workspaceReconciler.SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to setup workspace controller with manager", "controller", "Workspace")
os.Exit(1)
Expand Down

0 comments on commit 5c7fa0b

Please sign in to comment.