File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ type controllerManager struct {
94
94
// resourceLock forms the basis for leader election
95
95
resourceLock resourcelock.Interface
96
96
97
+ // leaderElectionReleaseOnCancel defines if the manager should step back from the leader lease
98
+ // on shutdown
99
+ leaderElectionReleaseOnCancel bool
100
+
97
101
// mapper is used to map resources to kind, and map kind and version.
98
102
mapper meta.RESTMapper
99
103
@@ -640,6 +644,7 @@ func (cm *controllerManager) startLeaderElection() (err error) {
640
644
},
641
645
OnStoppedLeading : cm .onStoppedLeading ,
642
646
},
647
+ ReleaseOnCancel : cm .leaderElectionReleaseOnCancel ,
643
648
})
644
649
if err != nil {
645
650
return err
Original file line number Diff line number Diff line change @@ -154,6 +154,13 @@ type Options struct {
154
154
// that is used to build the leader election client.
155
155
LeaderElectionConfig * rest.Config
156
156
157
+ // LeaderElectionReleaseOnCancel defines if the leader should step down voluntarily
158
+ // when the Manager ends. This requires the binary to immediately end when the
159
+ // Manager is stopped, otherwise this setting is unsafe. Setting this significantly
160
+ // speeds up voluntary leader transitions as the new leader doesn't have to wait
161
+ // LeaseDuration time first.
162
+ LeaderElectionReleaseOnCancel bool
163
+
157
164
// LeaseDuration is the duration that non-leader candidates will
158
165
// wait to force acquire leadership. This is measured against time of
159
166
// last observed ack. Default is 15 seconds.
You can’t perform that action at this time.
0 commit comments