You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: cmd/hubagent/options/leaderelection.go
+87-3Lines changed: 87 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,6 +18,8 @@ package options
18
18
19
19
import (
20
20
"flag"
21
+
"fmt"
22
+
"strconv"
21
23
"time"
22
24
23
25
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -53,6 +55,18 @@ type LeaderElectionOptions struct {
53
55
// The namespace of the resource object that will be used to lock during leader election cycles.
54
56
// This option only applies if leader election is enabled.
55
57
ResourceNamespacestring
58
+
59
+
// The QPS limit set to the rate limiter of the Kubernetes client in use by the controller manager
60
+
// for leader election purposes. This sets up a separate client-side throttling mechanism specifically
61
+
// for lease related operations, mostly to avoid an adverse situation where normal operations
62
+
// in the controller manager starve the lease related operations, and thus cause unexpected leadership losses.
63
+
LeaderElectionQPSfloat64
64
+
65
+
// The burst limit set to the rate limiter of the Kubernetes client in use by the controller manager
66
+
// for leader election purposes. This sets up a separate client-side throttling mechanism specifically
67
+
// for lease related operations, mostly to avoid an adverse situation where normal operations
68
+
// in the controller manager starve the lease related operations, and thus cause unexpected leadership losses.
69
+
LeaderElectionBurstint
56
70
}
57
71
58
72
// AddFlags adds flags for LeaderElectionOptions to the specified FlagSet.
@@ -69,23 +83,23 @@ func (o *LeaderElectionOptions) AddFlags(flags *flag.FlagSet) {
69
83
flags.DurationVar(
70
84
&o.LeaseDuration.Duration,
71
85
"leader-lease-duration",
72
-
15*time.Second,
86
+
60*time.Second,
73
87
"The duration of a leader election lease. This is the period where a non-leader candidate will wait after observing a leadership renewal before attempting to acquire leadership of the current leader. And it is also effectively the maximum duration that a leader can be stopped before it is replaced by another candidate. The option only applies if leader election is enabled.",
74
88
)
75
89
76
90
// This input is sent to the controller manager for validation; no further check here.
77
91
flags.DurationVar(
78
92
&o.RenewDeadline.Duration,
79
93
"leader-renew-deadline",
80
-
10*time.Second,
94
+
45*time.Second,
81
95
"The interval between attempts by the acting master to renew a leadership slot before it stops leading. This must be less than or equal to the lease duration. The option only applies if leader election is enabled",
82
96
)
83
97
84
98
// This input is sent to the controller manager for validation; no further check here.
85
99
flags.DurationVar(
86
100
&o.RetryPeriod.Duration,
87
101
"leader-retry-period",
88
-
2*time.Second,
102
+
5*time.Second,
89
103
"The duration the clients should wait between attempting acquisition and renewal of a leadership. The option only applies if leader election is enabled",
90
104
)
91
105
@@ -96,4 +110,74 @@ func (o *LeaderElectionOptions) AddFlags(flags *flag.FlagSet) {
96
110
utils.FleetSystemNamespace,
97
111
"The namespace of the resource object that will be used to lock during leader election cycles. The option only applies if leader election is enabled.",
"The QPS limit set to the rate limiter of the Kubernetes client in use by the controller manager for leader election purposes. This sets up a separate client-side throttling mechanism specifically for lease related operations, mostly to avoid an adverse situation where normal operations in the controller manager starve the lease related operations, and thus cause unexpected leadership losses. Defaults to 250. Use a positive float64 value in the range [10.0, 1000.0], or set a less or equal to zero value to disable client-side throttling.")
"The burst limit set to the rate limiter of the Kubernetes client in use by the controller manager for leader election purposes. This sets up a separate client-side throttling mechanism specifically for lease related operations, mostly to avoid an adverse situation where normal operations in the controller manager starve the lease related operations, and thus cause unexpected leadership losses. Defaults to 1000. Use a positive int value in the range [10, 2000].")
123
+
}
124
+
125
+
// A list of flag variables that allow pluggable validation logic when parsing the input args.
Copy file name to clipboardExpand all lines: cmd/hubagent/options/validation.go
+5Lines changed: 5 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -33,6 +33,11 @@ func (o *Options) Validate() field.ErrorList {
33
33
errs=append(errs, field.Invalid(newPath.Child("HubBurst"), o.CtrlMgrOpts.HubBurst, "The burst limit for client-side throttling must be greater than or equal to its QPS limit"))
34
34
}
35
35
36
+
// Cross-field validation for leader election options.
errs=append(errs, field.Invalid(newPath.Child("LeaderElectionBurst"), o.LeaderElectionOpts.LeaderElectionBurst, "The burst limit for client-side throttling of leader election related operations must be greater than or equal to its QPS limit"))
39
+
}
40
+
36
41
// Cross-field validation for webhook options.
37
42
38
43
// Note: this validation logic is a bit weird in the sense that the system accepts
want: field.ErrorList{field.Invalid(newPath.Child("HubBurst"), 50, "The burst limit for client-side throttling must be greater than or equal to its QPS limit")},
80
84
},
85
+
"invalid: leader election burst value is less than its QPS value": {
86
+
opt: newTestOptions(func(option*Options) {
87
+
option.LeaderElectionOpts.LeaderElectionQPS=100
88
+
option.LeaderElectionOpts.LeaderElectionBurst=50
89
+
}),
90
+
want: field.ErrorList{field.Invalid(newPath.Child("LeaderElectionBurst"), 50, "The burst limit for client-side throttling of leader election related operations must be greater than or equal to its QPS limit")},
0 commit comments