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

Leader to give up leadership lock on graceful shutdown #1460

Merged
merged 4 commits into from Dec 29, 2020

Conversation

himanshug
Copy link
Contributor

So that other candidate can become the next leader quickly or else other candidate might need to wait for full leaseDuration before getting the lock.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 26, 2020
*/
@Test(timeout = 20000L)
public void testLeaderGracefulShutdown() throws Exception {
LockSmith lockSmith = new LockSmith();
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like there is value in using WireMock and actually talking HTTP for the locks. How hard is it to switch to testing using WireMock like we do elsewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review.

Here we are more interested in testing the code of LeaderElector which can be tested as long as a well-behaving Lock implementation is provided. Also, truth is that it was just super simple/quick to do and does the job :) ... and followed in spirit the existing unit tests for leader election related code.

With WireMock, we would actually also test the implementation of Lock itself i.e. ConfigMapLock class etc. I haven't used WireMock in the past, so not sure about the work required, but will try to look into it.

that said, not sure but, I see there is an e2e build that appears to setup a real k8s cluster, how would you feel about this test running as an e2e integration test against real k8s cluster instead of the WireMock ?

Copy link
Contributor

Choose a reason for hiding this comment

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

e2e integration is even better :)

@brendandburns
Copy link
Contributor

Thanks, this looks good to me, but I'd rather see the tests actually use HTTP rather than an in-memory mock.

Also, I'd like @yue9944882 to take a look at this before we merge it, since he wrote most of this code.

Copy link
Member

@yue9944882 yue9944882 left a comment

Choose a reason for hiding this comment

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

thanks! it's generally a good idea to the perform graceful fore-ground shutdown.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 28, 2020
@brendandburns
Copy link
Contributor

/approve

Would love to have the integration test as a follow on PR. Thanks!

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: brendandburns, himanshug

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

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. 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

4 participants