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

Add Lease implementation to leaderelection package #70778

Merged
merged 1 commit into from
Jan 24, 2019

Conversation

wongma7
Copy link
Contributor

@wongma7 wongma7 commented Nov 8, 2018

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 #kubernetes/client-go#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 kubernetes/client-go#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
if spec.HolderIdentity != nil {
holderIdentity = *spec.HolderIdentity
}
leaseDurationSeconds := 0
Copy link
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.

return metav1.NewTime(t), nil
}

func timeToMicroTime(u *metav1.Time) (metav1.MicroTime, error) {
Copy link
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

Copy link
Member

@mikedanese mikedanese Nov 17, 2018

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
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
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
Copy link
Member

roycaihw commented Nov 8, 2018

/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
Copy link
Contributor Author

wongma7 commented Nov 20, 2018

/test pull-kubernetes-e2e-kops-aws

@liggitt
Copy link
Member

liggitt commented Dec 21, 2018

cc @wojtek-t

@wojtek-t
Copy link
Member

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

/assign @wojtek-t

@cheftako
Copy link
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
return ll.LockConfig.Identity
}

func LeaderElectionRecordToLeaseSpec(ler *LeaderElectionRecord) coordinationv1.LeaseSpec {
Copy link
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
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

@mikedanese
Copy link
Member

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

/approve

@k8s-ci-robot
Copy link
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

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
Member

LGTM

@wongma7
Copy link
Contributor Author

wongma7 commented Jan 23, 2019

squashed, thank you

@mikedanese
Copy link
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
Copy link
Contributor Author

wongma7 commented Jan 24, 2019

/retest

1 similar comment
@wongma7
Copy link
Contributor Author

wongma7 commented Jan 24, 2019

/retest

@k8s-ci-robot k8s-ci-robot merged commit d027ecf into kubernetes:master Jan 24, 2019
@k8s-ci-robot
Copy link
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.

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