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 election lock based on scheduler name #42961

Merged
merged 2 commits into from
Apr 6, 2017

Conversation

wanghaoran1988
Copy link
Contributor

@wanghaoran1988 wanghaoran1988 commented Mar 12, 2017

What this PR does / why we need it:
This pr changed the leader election lock based on scheduler name.
Which issue this PR fixes :
fixes #39032

Special notes for your reviewer:

Release note:

[scheduling]Fix a bug for multiple-schedulers that you cannot start a second scheduler without disabling leader-elect if the default scheduler has leader-elect enabled(default). We changed the leader election lock based on scheduler name.

@k8s-ci-robot
Copy link
Contributor

Hi @wanghaoran1988. 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 @k8s-bot 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.

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.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Mar 12, 2017
@k8s-reviewable
Copy link

This change is Reviewable

@k8s-github-robot k8s-github-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. release-note-label-needed labels Mar 12, 2017
@k8s-github-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

The following people have approved this PR: wanghaoran1988

Needs approval from an approver in each of these OWNERS Files:

We suggest the following people:
cc @davidopp
You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@wanghaoran1988
Copy link
Contributor Author

/cc @k82cn @timothysc

@@ -114,7 +114,7 @@ func Run(s *options.SchedulerServer) error {
rl := &resourcelock.EndpointsLock{
EndpointsMeta: metav1.ObjectMeta{
Namespace: "kube-system",
Name: "kube-scheduler",
Name: s.SchedulerName,
Copy link
Member

Choose a reason for hiding this comment

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

prefer to "kube-scheduler-" + s.SchedulerName

Copy link
Member

Choose a reason for hiding this comment

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

+1

@k82cn
Copy link
Member

k82cn commented Mar 12, 2017

@k8s-bot ok to test

@timothysc timothysc added sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. kind/bug Categorizes issue or PR as related to a bug. release-note-none Denotes a PR that doesn't merit a release note. and removed release-note-label-needed labels Mar 12, 2017
@timothysc timothysc added this to the v1.6 milestone Mar 12, 2017
@timothysc
Copy link
Member

@wanghaoran1988 please address comment and re-bazel and we can get the change in.

@wanghaoran1988
Copy link
Contributor Author

@timothysc @k82cn Comments addressed, and I am already passed hack/verify-bazel.sh locally, not clear why it failed, could you point me what should I do?

@ravilr
Copy link
Contributor

ravilr commented Mar 12, 2017

@timothysc IMO, this change warrants a release note. because, in HA setups with multiple instances of scheduler running and where upgrades are rolled out in a rolling manner, with this change after the upgrade, the new upgraded instance might acquire the lock while one of the old instances still holding the lock with old endpoint name. So, one should stop all old instances of scheduler before rolling out this change?

@davidopp
Copy link
Member

cc/ @kubernetes/sig-scheduling-pr-reviews

@timothysc timothysc added release-note-label-needed and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 13, 2017
@timothysc
Copy link
Member

timothysc commented Mar 13, 2017

@wanghaoran1988 please add a release note.

@k8s-bot test this #IGNORE

@wanghaoran1988
Copy link
Contributor Author

@timothysc Release note added

@k82cn
Copy link
Member

k82cn commented Mar 13, 2017

@wanghaoran1988 , please try /release-note command :).

@k8s-github-robot k8s-github-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-label-needed labels Mar 13, 2017
@timothysc
Copy link
Member

@k8s-bot test this #IGNORE

@jayunit100
Copy link
Member

jayunit100 commented Mar 13, 2017

thanks for this ! This might be why the scheduler_perf tests failed and went into lock frenzy when i tried to start them w/ a scheduling server

@enisoc enisoc modified the milestones: v1.6.1, v1.6 Mar 23, 2017
Copy link
Member

@k82cn k82cn left a comment

Choose a reason for hiding this comment

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

please put generated codes in different commit.

@@ -72,6 +72,8 @@ func (s *SchedulerServer) AddFlags(fs *pflag.FlagSet) {
fs.Float32Var(&s.KubeAPIQPS, "kube-api-qps", s.KubeAPIQPS, "QPS to use while talking with kubernetes apiserver")
fs.Int32Var(&s.KubeAPIBurst, "kube-api-burst", s.KubeAPIBurst, "Burst to use while talking with kubernetes apiserver")
fs.StringVar(&s.SchedulerName, "scheduler-name", s.SchedulerName, "Name of the scheduler, used to select which pods will be processed by this scheduler, based on pod's \"spec.SchedulerName\".")
fs.StringVar(&s.LockObjectNamespace, "lock-object-namespace", s.LockObjectNamespace, "Define the namespace of the lock object")
fs.StringVar(&s.LockObjectName, "lock-object-name", s.LockObjectName, "Define the name of the lock object")
Copy link
Member

Choose a reason for hiding this comment

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

The default value from cli should be DefaultLockObjectName .

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k82cn Addressed

@@ -4377,4 +4377,7 @@ const (
// When the --failure-domains scheduler flag is not specified,
// DefaultFailureDomains defines the set of label keys used when TopologyKey is empty in PreferredDuringScheduling anti-affinity.
DefaultFailureDomains string = metav1.LabelHostname + "," + metav1.LabelZoneFailureDomain + "," + metav1.LabelZoneRegion

// "kube-scheduler" is the default lock object name
DefaultLockObjectName = "kube-scheduler"
Copy link
Member

Choose a reason for hiding this comment

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

Where's DefaultLockObjectNamespace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k82cn I am using api.NamespaceSystem, correct me if I am wrong :)

Copy link
Member

@k82cn k82cn Mar 23, 2017

Choose a reason for hiding this comment

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

prefer to DefaultLockObjectNamespace = api.NamespaceSystem

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@k82cn Done

@wanghaoran1988 wanghaoran1988 force-pushed the fix_39032 branch 3 times, most recently from 6345610 to c76aacb Compare March 27, 2017 05:08
@wanghaoran1988
Copy link
Contributor Author

@k8s-bot gci gce e2e test this

@timothysc timothysc modified the milestones: v1.7, v1.6.1 Mar 30, 2017
@timothysc timothysc added approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Mar 30, 2017
pkg/api/types.go Outdated
DefaultLockObjectNamespace string = NamespaceSystem

// "kube-scheduler" is the default lock object name
DefaultLockObjectName = "kube-scheduler"
Copy link
Member

Choose a reason for hiding this comment

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

if this is exported from the API package, it needs a name that indicates it is for the scheduler

Copy link
Member

Choose a reason for hiding this comment

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

these really seems like they belong in the component config package, with names that scope them to the scheduler

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@liggitt Does SchedulerDefaultLockObjectNamespace, SchedulerDefaultLockObjectNamespace make sense to you ?

Copy link
Member

Choose a reason for hiding this comment

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

sure, something like that, and moved to the component config package

@timothysc timothysc removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 30, 2017
@wanghaoran1988
Copy link
Contributor Author

@k8s-bot non-cri e2e test this

@@ -218,6 +218,8 @@ const (
NamespaceDefault string = "default"
// NamespaceAll is the default argument to specify on a context when you want to list or filter resources across all namespaces
NamespaceAll string = ""
// NamespaceSystem is the system namespace where we place system components.
NamespaceSystem string = "kube-system"
Copy link
Member

Choose a reason for hiding this comment

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

Is this still needed now that you have SchedulerDefaultLockObjectNamespace ?

It looks like this is unused.

@wanghaoran1988
Copy link
Contributor Author

@k8s-bot non-cri e2e test this

@wanghaoran1988
Copy link
Contributor Author

@timothysc Updated, would you mind take a look again?

@timothysc timothysc added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2017
@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit 54f3868 into kubernetes:master Apr 6, 2017
@wanghaoran1988 wanghaoran1988 deleted the fix_39032 branch November 22, 2017 05:58
@lovejoy
Copy link
Contributor

lovejoy commented Jan 25, 2019

looks like we need to define scheduler-name & lock-object-name if we want to run multiple not-default scheduler

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/api-change Categorizes issue or PR as related to adding, removing, or otherwise changing an API 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. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/scheduling Categorizes an issue or PR as relevant to SIG Scheduling. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running multiple-schedulers with leader-elect