-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨ Agent leader election config #349
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,10 @@ type RegistrationConfiguration struct { | |
// +kubebuilder:default:=100 | ||
KubeAPIBurst int32 `json:"kubeAPIBurst,omitempty"` | ||
|
||
// Leader election configuration | ||
// +optional | ||
LeaderElectionConfig `json:",inline"` | ||
|
||
// BootstrapKubeConfigs defines the ordered list of bootstrap kubeconfigs. The order decides which bootstrap kubeconfig to use first when rebootstrap. | ||
// | ||
// When the agent loses the connection to the current hub over HubConnectionTimeoutSeconds, or the managedcluster CR | ||
|
@@ -269,6 +273,10 @@ type WorkAgentConfiguration struct { | |
// +kubebuilder:default:=100 | ||
KubeAPIBurst int32 `json:"kubeAPIBurst,omitempty"` | ||
|
||
// Leader election configuration | ||
// +optional | ||
LeaderElectionConfig `json:",inline"` | ||
|
||
// AppliedManifestWorkEvictionGracePeriod is the eviction grace period the work agent will wait before | ||
// evicting the AppliedManifestWorks, whose corresponding ManifestWorks are missing on the hub cluster, from | ||
// the managed cluster. If not present, the default value of the work agent will be used. | ||
|
@@ -278,6 +286,42 @@ type WorkAgentConfiguration struct { | |
AppliedManifestWorkEvictionGracePeriod *metav1.Duration `json:"appliedManifestWorkEvictionGracePeriod,omitempty"` | ||
} | ||
|
||
// Leader election configuration | ||
type LeaderElectionConfig struct { | ||
// Disable leader election. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we really need to expose every configurations here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the leader election will always be enabled in OCM single node case, and we are not 100% sure if it will impact the user's cases, it might be useful to provide a disable option in |
||
// Use the klusterlet agent default value if this field is not defined. | ||
// +optional | ||
DisableLeaderElection bool `json:"disableLeaderElection,omitempty"` | ||
|
||
// The duration that non-leader candidates will wait after observing a leadership | ||
// renewal until attempting to acquire leadership of a led but unrenewed leader | ||
// slot. This is effectively the maximum duration that a leader can be stopped | ||
// before it is replaced by another candidate. This is only applicable if leader | ||
// election is enabled. | ||
// Use the klusterlet agent default value if this field is not defined. | ||
// +optional | ||
// +kubebuilder:validation:Type=string | ||
// +kubebuilder:validation:Pattern="^([0-9]+(s|m|h))+$" | ||
LeaderElectionLeaseDuration *metav1.Duration `json:"leaderElectionLeaseDuration,omitempty"` | ||
|
||
// 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. | ||
// This is only applicable if leader election is enabled. | ||
// Use the klusterlet agent default value if this field is not defined. | ||
// +optional | ||
// +kubebuilder:validation:Type=string | ||
// +kubebuilder:validation:Pattern="^([0-9]+(s|m|h))+$" | ||
LeaderElectionRenewDeadline *metav1.Duration `json:"leaderElectionRenewDeadline,omitempty"` | ||
|
||
// The duration the clients should wait between attempting acquisition and renewal | ||
// of a leadership. This is only applicable if leader election is enabled. | ||
// Use the klusterlet agent default value if this field is not defined. | ||
// +optional | ||
// +kubebuilder:validation:Type=string | ||
// +kubebuilder:validation:Pattern="^([0-9]+(s|m|h))+$" | ||
LeaderElectionRetryPeriod *metav1.Duration `json:"leaderElectionRetryPeriod,omitempty"` | ||
} | ||
|
||
const ( | ||
// ClusterAnnotationsKeyPrefix is the prefix of annotations set on ManagedCluster when creating only. | ||
ClusterAnnotationsKeyPrefix = "agent.open-cluster-management.io" | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not think it needs to be inline.