-
Notifications
You must be signed in to change notification settings - Fork 68
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
add leader election options #133
add leader election options #133
Conversation
/retest-required |
4ad3723
to
4039544
Compare
/retest |
1 similar comment
/retest |
main.go
Outdated
MetricsBindAddress: metricsPort, | ||
LeaderElectionNamespace: leaderElectionConfig.ResourceNamespace, | ||
LeaderElection: leaderElectionConfig.LeaderElect, | ||
LeaseDuration: &leaderElectionConfig.LeaseDuration.Duration, |
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.
Please let's set LeaderElectionResourceLock: resourcelock.LeasesResourceLock
otherwise controller runtime defaults to configmapsleases
manifests/01-rbac.yaml
Outdated
- "" | ||
- "coordination.k8s.io" | ||
resources: | ||
- configmaps |
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.
There's no need for additional rbac for configmaps, only leases https://github.com/openshift/cluster-machine-approver/pull/133/files#r726013249
main.go
Outdated
@@ -56,7 +73,11 @@ func main() { | |||
flagSet.StringVar(&machineNamespace, "machine-namespace", "", "restrict machine operations to a specific namespace, if not set, all machines will be observed in approval decisions") | |||
flagSet.StringVar(&workloadKubeConfigPath, "workload-cluster-kubeconfig", "", "workload kubeconfig path") | |||
|
|||
flagSet.Parse(os.Args[1:]) | |||
// Once all the flags are regitered, switch to pflag |
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.
not sure I follow this comment, mind elaborating?
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.
sure BindLeaderElectionFlags is expecting a pflag as input variable, so I converted the original flags into pflag type. (same as cccmo)
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.
Isn't this exposing more than we need as a flags, e.g ResourceLock?
If I would just expose the ones we need manually, no need for the library.
what is CCCMO? |
main.go
Outdated
// Default leader electrion configuration. | ||
leaderElectionConfig = config.LeaderElectionConfiguration{ | ||
LeaderElect: true, | ||
LeaseDuration: metav1.Duration{Duration: 137 * time.Second}, |
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.
why did you choose this values?
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.
copied from this commit of cccmo: openshift/cluster-cloud-controller-manager-operator@445bfe3
https://github.com/openshift/cluster-cloud-controller-manager-operator/ the new operator for managing CCMs on openshift |
+1 that CCCMO is |
4039544
to
f9b0b6e
Compare
Thanks! Just one comment #133 (comment) |
f9b0b6e
to
b979639
Compare
/lgtm |
b979639
to
33128e4
Compare
/test e2e-aws |
/test e2e-upgrade |
/retest |
@@ -58,6 +66,12 @@ func main() { | |||
flagSet.StringVar(&workloadKubeConfigPath, "workload-cluster-kubeconfig", "", "workload kubeconfig path") | |||
flagSet.BoolVar(&disableStatusController, "disable-status-controller", false, "disable status controller that will update the machine-approver clusteroperator status") | |||
|
|||
flagSet.BoolVar(&leaderElect, "leader-elect", true, "use leader election when starting the manager.") |
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.
do we want it true by default?
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.
One quick change, otherwise LGTM
main.go
Outdated
@@ -90,7 +104,14 @@ func main() { | |||
// Create a new Cmd to provide shared dependencies and start components | |||
klog.Info("setting up manager") | |||
mgr, err := manager.New(workloadConfig, manager.Options{ | |||
MetricsBindAddress: metricsPort, | |||
MetricsBindAddress: metricsPort, |
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.
Please add ReleaseOnCancel: true
else this will cause approx 3 minute delays during upgrades
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.
updated with LeaderElectionReleaseOnCancel: true
go func() { | ||
<-mgr.Elected() | ||
statusController.Run(1, stop) | ||
}() |
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.
Weird that we run this separately, I'll make a note to look into this
Signed-off-by: Hanqiu Zhang <hanzhang@redhat.com>
33128e4
to
a135d50
Compare
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/retest |
1 similar comment
/retest |
@hanqiuzh: The following test failed, say
Full PR test history. Your PR dashboard. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
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.
thanks @hanqiuzh !
/lgtm
Updates:
Tests: