Skip to content

Commit

Permalink
fix: leaderelection uses the lock in the same ns as the controller
Browse files Browse the repository at this point in the history
- if not provided, the lock is in argo-rollouts
- remove leader namespace from cli arguments

Signed-off-by: Hui Kang <[email protected]>
  • Loading branch information
Hui Kang committed Dec 15, 2021
1 parent 5b140c9 commit a6d67dc
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
1 change: 0 additions & 1 deletion cmd/rollouts-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ func newCommand() *cobra.Command {
command.Flags().BoolVar(&awsVerifyTargetGroup, "aws-verify-target-group", false, "Verify ALB target group before progressing through steps (requires AWS privileges)")
command.Flags().BoolVar(&printVersion, "version", false, "Print version")
command.Flags().BoolVar(&electOpts.LeaderElect, "leader-elect", controller.DefaultLeaderElect, "If true, controller will perform leader election between instances to ensure no more than one instance of controller operates at a time")
command.Flags().StringVar(&electOpts.LeaderElectionNamespace, "leader-election-namespace", controller.DefaultLeaderElectionNamespace, "Namespace used to perform leader election. Only used if leader election is enabled")
command.Flags().DurationVar(&electOpts.LeaderElectionLeaseDuration, "leader-election-lease-duration", controller.DefaultLeaderElectionLeaseDuration, "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.")
command.Flags().DurationVar(&electOpts.LeaderElectionRenewDeadline, "leader-election-renew-deadline", controller.DefaultLeaderElectionRenewDeadline, "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.")
command.Flags().DurationVar(&electOpts.LeaderElectionRetryPeriod, "leader-election-retry-period", controller.DefaultLeaderElectionRetryPeriod, "The duration the clients should wait between attempting acquisition and renewal of a leadership. This is only applicable if leader election is enabled.")
Expand Down
5 changes: 1 addition & 4 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ const (
// DefaultLeaderElect is the default true leader election should be enabled
DefaultLeaderElect = true

// DefaultLeaderElectionNamespace is the default namespace used to perform leader election. Only used if leader election is enabled
DefaultLeaderElectionNamespace = "kube-system"

// DefaultLeaderElectionLeaseDuration is the default time in seconds that non-leader candidates will wait to force acquire leadership
DefaultLeaderElectionLeaseDuration = 15 * time.Second

Expand All @@ -103,7 +100,7 @@ type LeaderElectionOptions struct {
func NewLeaderElectionOptions() *LeaderElectionOptions {
return &LeaderElectionOptions{
LeaderElect: DefaultLeaderElect,
LeaderElectionNamespace: DefaultLeaderElectionNamespace,
LeaderElectionNamespace: defaults.Namespace(),
LeaderElectionLeaseDuration: DefaultLeaderElectionLeaseDuration,
LeaderElectionRenewDeadline: DefaultLeaderElectionRenewDeadline,
LeaderElectionRetryPeriod: DefaultLeaderElectionRetryPeriod,
Expand Down

0 comments on commit a6d67dc

Please sign in to comment.