-
Notifications
You must be signed in to change notification settings - Fork 39.8k
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
Conversation
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 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. |
[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 @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, |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@k8s-bot ok to test |
@wanghaoran1988 please address comment and re-bazel and we can get the change in. |
33a5389
to
59bb6a7
Compare
@timothysc @k82cn Comments addressed, and I am already passed |
@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? |
cc/ @kubernetes/sig-scheduling-pr-reviews |
@wanghaoran1988 please add a release note. @k8s-bot test this #IGNORE |
@timothysc Release note added |
@wanghaoran1988 , please try /release-note command :). |
@k8s-bot test this #IGNORE |
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 |
There was a problem hiding this 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") |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k82cn Addressed
pkg/api/v1/types.go
Outdated
@@ -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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where's DefaultLockObjectNamespace
?
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@k82cn Done
6345610
to
c76aacb
Compare
@k8s-bot gci gce e2e test this |
pkg/api/types.go
Outdated
DefaultLockObjectNamespace string = NamespaceSystem | ||
|
||
// "kube-scheduler" is the default lock object name | ||
DefaultLockObjectName = "kube-scheduler" |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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
c76aacb
to
c0190cf
Compare
@k8s-bot non-cri e2e test this |
pkg/api/v1/types.go
Outdated
@@ -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" |
There was a problem hiding this comment.
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.
c0190cf
to
251abaa
Compare
@k8s-bot non-cri e2e test this |
@timothysc Updated, would you mind take a look again? |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue |
looks like we need to define scheduler-name & lock-object-name if we want to run multiple not-default scheduler |
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: