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

Flag to disable Leader Election Feature on Nginx Controller #11064

Merged

Conversation

msfidelis
Copy link
Contributor

What this PR does / why we need it:

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • CVE Report (Scanner found CVE and adding report)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation only

Which issue/s this PR fixes

fixes #8919

How Has This Been Tested?

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I've read the CONTRIBUTION guide
  • I have added unit and/or e2e tests to cover my changes.
  • All new and existing tests passed.

Copy link

linux-foundation-easycla bot commented Mar 4, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: msfidelis / name: Matheus Fidelis (16afa03)

@k8s-ci-robot k8s-ci-robot added area/docs needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Mar 4, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @msfidelis!

It looks like this is your first PR to kubernetes/ingress-nginx 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/ingress-nginx has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @msfidelis. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. needs-priority cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2024
Copy link

netlify bot commented Mar 4, 2024

Deploy Preview for kubernetes-ingress-nginx canceled.

Name Link
🔨 Latest commit 16afa03
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-ingress-nginx/deploys/65e7c84c5f3176000807f8b3

@rikatz
Copy link
Contributor

rikatz commented Mar 4, 2024

/check-cla
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 4, 2024
@strongjz
Copy link
Member

strongjz commented Mar 4, 2024

Please add an e2e test with the leader election set to false.

Also, I like the idea of making that configurable as well, the leader election TTL. Can you add that and make the default 30 seconds?

ttl := 30 * time.Second
elector, err := leaderelection.NewLeaderElector(leaderelection.LeaderElectionConfig{
Lock: &lock,
LeaseDuration: ttl,
RenewDeadline: ttl / 2,
RetryPeriod: ttl / 4,

@strongjz strongjz requested review from strongjz and rikatz and removed request for puerco and cpanato March 4, 2024 15:14
@rikatz
Copy link
Contributor

rikatz commented Mar 4, 2024

/triage accepted
/priority backlog
/kind feature

@strongjz
Copy link
Member

strongjz commented Mar 4, 2024

/triage accepted
/kind feature

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/backlog Higher priority than priority/awaiting-more-evidence. kind/feature Categorizes issue or PR as related to a new feature. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority labels Mar 4, 2024
@strongjz
Copy link
Member

strongjz commented Mar 4, 2024

--leader-election-enabled default true.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 4, 2024
Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

some comment, overall looks good

Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

Same

test/e2e/disableleaderelection/disable_leader.go Outdated Show resolved Hide resolved
@rikatz
Copy link
Contributor

rikatz commented Mar 5, 2024

Ok, so:

  • e2e tests seems to work fine 🥳 just remove all of the comments and unused variables (keep the file clean). BTW, great approach on having 2 ingresses and testing both!
  • @strongjz maybe we can do the leader election timeout on another PR, up to you and @msfidelis but as this was a "good first issue" I'm worried about overloading it. We will not be able to really e2e test the leader election timeout with some fancy "kill pod, wait it to change to another pod name, etc", so I think we can do it as a follow up (it is going to be a fun e2e test to write tho).
  • @msfidelis now we need to fix the helm docs, which should be just running helm docs make (or something like that, my memory is bad, I'm getting old).

Other than the points above, I think it is already fine to move. @strongjz I would just avoid cherry-picking this as it is not a bug, but a feature

/approve
/hold

Will wait for some other reviewers + the fixes I've asked before lgtm'ing and unholding

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Mar 5, 2024
@strongjz
Copy link
Member

strongjz commented Mar 5, 2024

That's fine for a follow-up.

Do we still want it to be a positive config option?

I'm on mobile right now so idk why helm docs is upset.

@cpanato
Copy link
Member

cpanato commented Mar 5, 2024

helm doc needs to be updated

+| controller.disableLeaderElection | bool | `false` | This configuration disable Nginx Controller Leader Election Defaults to false |

Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

also need to fix the lint

[lint: test/e2e/disableleaderelection/disable_leader.go#L28](https://github.com/kubernetes/ingress-nginx/pull/11064/files#annotation_18883045317)
var `cfgOK` is unused (unused)

@msfidelis
Copy link
Contributor Author

Hello @strongjz ! Thank you for your attention and for the review. I think these suggestions would be very interesting. What you thing if I submitted these new TTL feature for Leader Election in a smaller and more focused PR?

Please add an e2e test with the leader election set to false.

Also, I like the idea of making that configurable as well, the leader election TTL. Can you add that and make the default 30 seconds?

ttl := 30 * time.Second
elector, err := leaderelection.NewLeaderElector(leaderelection.LeaderElectionConfig{
Lock: &lock,
LeaseDuration: ttl,
RenewDeadline: ttl / 2,
RetryPeriod: ttl / 4,

@msfidelis
Copy link
Contributor Author

Hello @cpanato and @rikatz !! Thank you very much for the support. It's an honor for me to be able to count on you at this time.

I have made the lint corrections, helm-docs and add more unit and e2e tests.

pkg/flags/flags_test.go Outdated Show resolved Hide resolved
@msfidelis msfidelis force-pushed the feature/disable_leader_election branch from aaf9949 to 16afa03 Compare March 6, 2024 01:35
@rikatz
Copy link
Contributor

rikatz commented Mar 6, 2024

/lgtm
/approve
@cpanato leaving for you to remove the hold

@msfidelis thank you very much for your contribution

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 6, 2024
@cpanato
Copy link
Member

cpanato commented Mar 6, 2024

/lgtm /approve @cpanato leaving for you to remove the hold

@msfidelis thank you very much for your contribution

i was about to do the same 😂

/honk

@k8s-ci-robot
Copy link
Contributor

@cpanato:
goose image

In response to this:

/lgtm /approve @cpanato leaving for you to remove the hold

@msfidelis thank you very much for your contribution

i was about to do the same 😂

/honk

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.

Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

thanks for this PR

/lgtm
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Mar 6, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, msfidelis, rikatz

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 merged commit 9b63559 into kubernetes:main Mar 6, 2024
29 checks passed
@strongjz strongjz added this to the release-1.11 milestone Mar 6, 2024
@Gacko Gacko mentioned this pull request Mar 11, 2024
10 tasks
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/docs area/helm Issues or PRs related to helm charts cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/backlog Higher priority than priority/awaiting-more-evidence. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable leader-election
5 participants