@@ -365,17 +365,11 @@ func main() {
365365 HealthProbeBindAddress : probeAddr ,
366366 LeaderElection : enableLeaderElection ,
367367 LeaderElectionID : "2fa1c467.opensandbox.io" ,
368- // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
369- // when the Manager ends. This requires the binary to immediately end when the
370- // Manager is stopped, otherwise, this setting is unsafe. Setting this significantly
371- // speeds up voluntary leader transitions as the new leader don't have to wait
372- // LeaseDuration time first.
373- //
374- // In the default scaffold provided, the program ends immediately after
375- // the manager stops, so would be fine to enable this option. However,
376- // if you are doing or is intended to do any operation such as perform cleanups
377- // after the manager stops then its usage might be unsafe.
378- // LeaderElectionReleaseOnCancel: true,
368+ // LeaderElectionReleaseOnCancel causes the leader to voluntarily release the lease
369+ // when the Manager is stopped, allowing a new leader to acquire it without waiting
370+ // for the full LeaseDuration. This is safe because main() exits immediately after
371+ // mgr.Start() returns and performs no post-stop cleanup.
372+ LeaderElectionReleaseOnCancel : true ,
379373 })
380374 if err != nil {
381375 setupLog .Error (err , "unable to start manager" )
@@ -404,10 +398,11 @@ func main() {
404398 os .Exit (1 )
405399 }
406400 if err := (& controller.PoolReconciler {
407- Client : mgr .GetClient (),
408- Scheme : mgr .GetScheme (),
409- Recorder : mgr .GetEventRecorderFor ("pool-controller" ),
410- Allocator : controller .NewDefaultAllocator (mgr .GetClient ()),
401+ Client : mgr .GetClient (),
402+ Scheme : mgr .GetScheme (),
403+ Recorder : mgr .GetEventRecorderFor ("pool-controller" ),
404+ Allocator : controller .NewDefaultAllocator (mgr .GetClient ()),
405+ RestConfig : mgr .GetConfig (),
411406 }).SetupWithManager (mgr , poolConcurrency ); err != nil {
412407 setupLog .Error (err , "unable to create controller" , "controller" , "Pool" )
413408 os .Exit (1 )
0 commit comments