Skip to content
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

Default LeaderElectionResourceLock to leases #1764

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Oct 6, 2021

What type of PR is this?

What this PR does / why we need it: Controller runtime sets by default leader-election-resource-lock to ConfigMapsLeasesResourceLock so consumers can do smooth transitions.
This PR default our controller to leases.

This mitigates overwhelming the apiserver in a large management cluster and avoids additional rbac.

refer to kubernetes-sigs/cluster-api#5388 and https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/book/src/developer/providers/v1alpha4-to-v1beta1.md#warning-leaderelectionresourcelock-change-warning

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1761

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Default LeaderElectionResource to v1.Lease

@k8s-ci-robot k8s-ci-robot added the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Oct 6, 2021
@k8s-ci-robot k8s-ci-robot added area/provider/azure Issues or PRs related to azure provider sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Oct 6, 2021
@CecileRobertMichon
Copy link
Contributor Author

/assign @enxebre @shysank @devigned

@shysank
Copy link
Contributor

shysank commented Oct 7, 2021

We are using controller runtime v0.5.14 in capz v0.4.15. Will this be a problem when users upgrade from 0.4.15?

@CecileRobertMichon
Copy link
Contributor Author

@shysank why do you say that? @enxebre do you know if there is a problem with upgrading from controller runtime v0.5.14? If there is, it would be the same for CAPA as their latest alpha3 release v0.6.8 is also using controller runtime v0.5.14 https://github.com/kubernetes-sigs/cluster-api-provider-aws/blob/v0.6.8/go.mod kubernetes-sigs/cluster-api-provider-aws#2822

@shysank
Copy link
Contributor

shysank commented Oct 7, 2021

@shysank why do you say that?

My understanding is controller-runtime prior to v0.7 defaulted lock resource to configmaps, and then v0.7 changed it to multi lock with configmaps + leases so that it doesn't break when we switch to only leases. That's why I was wondering what would happen if we switched directly from configmaps to leases.

@enxebre
Copy link
Member

enxebre commented Oct 8, 2021

There's a risk for users going from "configmaps" -> "leases". My understanding is that upgrades through clusterctl stop the old controllers before running the new ones during an upgrade, if that's the case we are all good.

Users relying on custom upgrades procedures should either ensure a migration to multilock "configmapsleases" first, which will acquire a leader lock on both resources and then proceed to "leases" or ensure the old controllers are stopped before running the new ones with the new lock mechanism. Otherwise, the controller might end up with multiple running instances that each acquired leadership through different resource locks during upgrades and thus act on the same resources concurrently. https://github.com/kubernetes-sigs/cluster-api/blob/main/docs/book/src/developer/providers/v1alpha4-to-v1beta1.md#warning-leaderelectionresourcelock-change-warning

tldr if old controllers are stopped before running the new ones all good.

@shysank
Copy link
Contributor

shysank commented Oct 8, 2021

/lgtm since old controllers are going to be removed first before the new ones are installed. One thing we should perhaps confirm is to check if there are no dangling config maps that were created for acquiring locks. I'm guessing they will be garbage collected.

Copy link
Contributor

@devigned devigned left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2021
@CecileRobertMichon
Copy link
Contributor Author

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 11, 2021
@k8s-ci-robot k8s-ci-robot merged commit 5148bae into kubernetes-sigs:main Oct 11, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.5 milestone Oct 11, 2021
@CecileRobertMichon CecileRobertMichon modified the milestones: v0.5, v1.0 Oct 28, 2021
@CecileRobertMichon CecileRobertMichon deleted the leader-election-resourcelock branch February 17, 2023 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/provider/azure Issues or PRs related to azure provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controller managers should use "leases" for leader-election-resource-lock
5 participants