Skip to content

Add Lease implementation to leaderelection package#70778

Merged
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
wongma7:lease
Jan 24, 2019
Merged

Add Lease implementation to leaderelection package#70778
k8s-ci-robot merged 1 commit into
kubernetes:masterfrom
wongma7:lease

Conversation

@wongma7

@wongma7 wongma7 commented Nov 8, 2018

Copy link
Copy Markdown
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it: enables components to use coordination/Lease objects for leaderelection as opposed to endpoints/configmaps. e.g. https://github.com/kubernetes-csi/external-attacher (which doesn't need the configmap) and https://github.com/kubernetes-csi/external-provisioner/ (which is currently using endpoints (oops) and would like to move away)

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 #https://github.com/kubernetes/client-go/issues/499

Special notes for your reviewer: Don't know if this is wanted, I see the Lease object is used by kubelet but don't see it anywhere else. Created https://github.com/kubernetes/client-go/issues/499 & didn't get a response.

Does this PR introduce a user-facing change?:

NONE

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/feature Categorizes issue or PR as related to a new feature. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. 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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Nov 8, 2018
@k8s-ci-robot k8s-ci-robot added 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 Nov 8, 2018
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/leaselock.go Outdated
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/leaselock.go Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this allows empty holder identity and zero lease duration in the record, which looks slightly odd. but stepping thru the elector, it will work fine i suppose.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AcquireTime metav1.Time `json:"acquireTime"`
RenewTime metav1.Time `json:"renewTime"`

can we switch them to micro time? @mikedanese

@mikedanese mikedanese Nov 17, 2018

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@wongma7 why is this helpful?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm, I see that LeaseSpec went with microtime. It should be fine. We don't actually use it to implement correctness. Also metav1.MicroTime to metav1.Time is just:

time := metav1.Time{microTime.Time}

No need for this function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

wow 👍 fixed in new patch

@roycaihw

roycaihw commented Nov 8, 2018

Copy link
Copy Markdown
Member

/cc @cheftako

@k8s-ci-robot k8s-ci-robot requested a review from cheftako November 8, 2018 21:27
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 16, 2018
@wongma7 wongma7 force-pushed the lease branch 2 times, most recently from 91f527d to 5da7a58 Compare November 20, 2018 15:32
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 20, 2018
@wongma7

wongma7 commented Nov 20, 2018

Copy link
Copy Markdown
Contributor Author

/test pull-kubernetes-e2e-kops-aws

@liggitt

liggitt commented Dec 21, 2018

Copy link
Copy Markdown
Member

cc @wojtek-t

@wojtek-t

Copy link
Copy Markdown
Member

Thanks for linking @liggitt !
I will take a look right after Christmas.

/assign @wojtek-t

@cheftako

Copy link
Copy Markdown
Member

/assign

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 13, 2019
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2019
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go Outdated
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go Outdated
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/leaderelection_test.go Outdated
Comment thread staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/interface.go Outdated
return ll.LockConfig.Identity
}

func LeaderElectionRecordToLeaseSpec(ler *LeaderElectionRecord) coordinationv1.LeaseSpec {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

make this private

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

can't access from leaderelection/leaderelection_test.go otherwise, same as the new leaseSpecToLeaderElectionRecord

Comment thread staging/src/k8s.io/client-go/tools/leaderelection/resourcelock/leaselock.go Outdated
@mikedanese

Copy link
Copy Markdown
Member

I'm generally happy with this. Had a couple suggestions.

/approve

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: mikedanese, wongma7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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 Jan 22, 2019
@mikedanese

Copy link
Copy Markdown
Member

LGTM

@wongma7

wongma7 commented Jan 23, 2019

Copy link
Copy Markdown
Contributor Author

squashed, thank you

@mikedanese

Copy link
Copy Markdown
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 23, 2019
@wongma7

wongma7 commented Jan 24, 2019

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@wongma7

wongma7 commented Jan 24, 2019

Copy link
Copy Markdown
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot merged commit d027ecf into kubernetes:master Jan 24, 2019
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

@wongma7: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kops-aws 4101758 link /test pull-kubernetes-e2e-kops-aws

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

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.

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/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. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. 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.

9 participants