@@ -113,6 +113,17 @@ type Options struct {
113
113
// will use for holding the leader lock.
114
114
LeaderElectionID string
115
115
116
+ // LeaseDuration is the duration that non-leader candidates will
117
+ // wait to force acquire leadership. This is measured against time of
118
+ // last observed ack. Default is 15 seconds.
119
+ LeaseDuration * time.Duration
120
+ // RenewDeadline is the duration that the acting master will retry
121
+ // refreshing leadership before giving up. Default is 10 seconds.
122
+ RenewDeadline * time.Duration
123
+ // RetryPeriod is the duration the LeaderElector clients should wait
124
+ // between tries of actions. Default is 2 seconds.
125
+ RetryPeriod * time.Duration
126
+
116
127
// Namespace if specified restricts the manager's cache to watch objects in
117
128
// the desired namespace Defaults to all namespaces
118
129
//
@@ -173,6 +184,7 @@ func (r RunnableFunc) Start(s <-chan struct{}) error {
173
184
}
174
185
175
186
// New returns a new Manager for creating Controllers.
187
+ // nolint: gocyclo
176
188
func New (config * rest.Config , options Options ) (Manager , error ) {
177
189
// Initialize a rest.config if none was specified
178
190
if config == nil {
@@ -231,6 +243,17 @@ func New(config *rest.Config, options Options) (Manager, error) {
231
243
232
244
stop := make (chan struct {})
233
245
246
+ leaseDuration , renewDeadline , retryPeriod := defaultLeaseDuration , defaultRenewDeadline , defaultRetryPeriod
247
+ if options .LeaseDuration == nil {
248
+ leaseDuration = defaultLeaseDuration
249
+ }
250
+ if options .RenewDeadline == nil {
251
+ renewDeadline = defaultRenewDeadline
252
+ }
253
+ if options .RetryPeriod == nil {
254
+ retryPeriod = defaultRetryPeriod
255
+ }
256
+
234
257
return & controllerManager {
235
258
config : config ,
236
259
scheme : options .Scheme ,
@@ -247,6 +270,9 @@ func New(config *rest.Config, options Options) (Manager, error) {
247
270
internalStopper : stop ,
248
271
port : options .Port ,
249
272
host : options .Host ,
273
+ leaseDuration : leaseDuration ,
274
+ renewDeadline : renewDeadline ,
275
+ retryPeriod : retryPeriod ,
250
276
}, nil
251
277
}
252
278
0 commit comments