@@ -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.
119
+ LeaseDurationSeconds * time.Duration
120
+ // RenewDeadline is the duration that the acting master will retry
121
+ // refreshing leadership before giving up.
122
+ RenewDeadlineSeconds * time.Duration
123
+ // RetryPeriod is the duration the LeaderElector clients should wait
124
+ // between tries of actions.
125
+ RetryPeriodSeconds * 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
//
@@ -231,22 +242,36 @@ func New(config *rest.Config, options Options) (Manager, error) {
231
242
232
243
stop := make (chan struct {})
233
244
245
+ leaseDuration , renewDeadline , retryPeriod := defaultLeaseDuration , defaultRenewDeadline , defaultRetryPeriod
246
+ if options .LeaseDurationSeconds == nil {
247
+ leaseDuration = defaultLeaseDuration
248
+ }
249
+ if options .RenewDeadlineSeconds == nil {
250
+ renewDeadline = defaultRenewDeadline
251
+ }
252
+ if options .RetryPeriodSeconds == nil {
253
+ retryPeriod = defaultRetryPeriod
254
+ }
255
+
234
256
return & controllerManager {
235
- config : config ,
236
- scheme : options .Scheme ,
237
- errChan : make (chan error ),
238
- cache : cache ,
239
- fieldIndexes : cache ,
240
- client : writeObj ,
241
- apiReader : apiReader ,
242
- recorderProvider : recorderProvider ,
243
- resourceLock : resourceLock ,
244
- mapper : mapper ,
245
- metricsListener : metricsListener ,
246
- internalStop : stop ,
247
- internalStopper : stop ,
248
- port : options .Port ,
249
- host : options .Host ,
257
+ config : config ,
258
+ scheme : options .Scheme ,
259
+ errChan : make (chan error ),
260
+ cache : cache ,
261
+ fieldIndexes : cache ,
262
+ client : writeObj ,
263
+ apiReader : apiReader ,
264
+ recorderProvider : recorderProvider ,
265
+ resourceLock : resourceLock ,
266
+ mapper : mapper ,
267
+ metricsListener : metricsListener ,
268
+ internalStop : stop ,
269
+ internalStopper : stop ,
270
+ port : options .Port ,
271
+ host : options .Host ,
272
+ leaseDurationSeconds : leaseDuration ,
273
+ renewDeadlineSeconds : renewDeadline ,
274
+ retryPeriodSeconds : retryPeriod ,
250
275
}, nil
251
276
}
252
277
0 commit comments