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

Fix leader election lock release when using LeaseLocks #80954

Merged
merged 2 commits into from Oct 27, 2020

Conversation

zachomedia
Copy link
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:

Resolves lock release issues with leader election when using LeaseLocks when ReleaseOnCancel is set to true (like in the example https://github.com/kubernetes/client-go/blob/master/examples/leader-election/main.go):

Failed to release lock: Lease.coordination.k8s.io "example" is invalid: spec.leaseDurationSeconds: Invalid value: 0: must be greater than 0

This PR updates the LeaderElectionRecord generated in the release function to:

  1. Set the LeaseDurationSeconds to 1 so that it's valid with LeaseLocks
  2. Fill in RenewTime and AcquireTime since it panics without that information

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

NONE

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot
Copy link
Contributor

Welcome @zachomedia!

It looks like this is your first PR to kubernetes/kubernetes 🎉. 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/kubernetes 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 k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Aug 3, 2019
@k8s-ci-robot
Copy link
Contributor

Hi @zachomedia. 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. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Aug 3, 2019
@yue9944882
Copy link
Member

/cc @mikedanese
/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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Aug 5, 2019
@zachomedia
Copy link
Contributor Author

Is it possible to get an update on this pull request?

cc @resouer @mikedanese @deads2k

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 16, 2020
@zachomedia
Copy link
Contributor Author

/remove-lifecycle stale

cc @resouer @mikedanese @deads2k

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 17, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 16, 2020
@zachomedia
Copy link
Contributor Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 21, 2020
@zachomedia
Copy link
Contributor Author

@resouer @mikedanese @deads2k Is there any possibility at getting this PR looked at? While it seems minor, I did spend the time to find the issue and a fix for it. It would be great to receive some feedback (it may not be the right way to fix this) and/or have it merged into the actual code base (if it's a reasonable fix), especially since it's been open for over 8 months now.

@mikedanese
Copy link
Member

Hi @zachomedia, thanks for the fix. Can you please add a test to demonstrate the issue and so that we don't regress when we fix it?

@mikedanese mikedanese added priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Apr 22, 2020
@liggitt
Copy link
Member

liggitt commented Aug 31, 2020

/hold

#88192 is touching the same place but handles the leader release differently. @smarterclayton which should we proceed with?

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 31, 2020
@mikedanese
Copy link
Member

@liggitt the two changes are functionally equivalent, so it's just a matter of what information we want to convey to the user until the next leader picks up. I like that this has a test.

@ChrsMark
Copy link
Contributor

Hey folks! Would be nice to have it in soon since it's has been around for some time now and it seems that it's just lacks the final ok to go. @liggitt @mikedanese is there anything blocking this?

@liggitt
Copy link
Member

liggitt commented Oct 26, 2020

/test all
/hold cancel

+1 for the test

@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 Oct 26, 2020
@zachomedia
Copy link
Contributor Author

/retest

@zachomedia
Copy link
Contributor Author

@liggitt I'm not sure what to do about the tests, it seems to be a different one that fails every time. I think a run of that test passed based on https://prow.k8s.io/pr-history/?org=kubernetes&repo=kubernetes&pr=80954 though?

@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

1 similar comment
@fejta-bot
Copy link

/retest
This bot automatically retries jobs that failed/flaked on approved PRs (send feedback to fejta).

Review the full test history for this PR.

Silence the bot with an /lgtm cancel or /hold comment for consistent failures.

@dprotaso
Copy link
Contributor

dprotaso commented Oct 27, 2020

Is this PR eligible to cherry pick back through v1.18.x?

@liggitt
Copy link
Member

liggitt commented Oct 27, 2020

yes

@dprotaso
Copy link
Contributor

Done!

k8s-ci-robot added a commit that referenced this pull request Oct 28, 2020
…54-upstream-release-1.18

Automated cherry pick of #80954: Generate complete leader election record to resolve
k8s-ci-robot added a commit that referenced this pull request Oct 28, 2020
…80954-upstream-release-1.17

Automated cherry pick of #80954: Generate complete leader election record to resolve
k8s-ci-robot added a commit that referenced this pull request Oct 28, 2020
…54-upstream-release-1.19

Automated cherry pick of #80954: Generate complete leader election record to resolve
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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. 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/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants