-
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
Move hardPodAffinitySymmetricWeight to scheduler policy config #44159
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. |
/cc @k82cn |
plugin/pkg/scheduler/api/v1/types.go
Outdated
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule | ||
// corresponding to every RequiredDuringScheduling affinity rule. | ||
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100. | ||
HardPodAffinitySymmetricWeight int |
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 *int
; the user may set it to 0.
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 If you don't set it, it will be 0.
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 I set it to 0 and also set hard-pod-affinity-symmetric-weight
, does it have the same behaviour with setting it to 1?
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 yes, 1 is the default value for hard-pod-affinity-symmetric-weight
from command line, but if the HardPodAffinitySymmetricWeight
from policy config is not 0, will use this .
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 concern is that: the behaviour is different when I set HardPodAffinitySymmetricWeight
in policy file: 0 vs. not-zero.
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.
Wait! Are we changing the existing behavior of HardPodAffinitySymmetricWeight
or just its location? If the answer is the latter, then we shouldn't change the type.
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.
It's a kind of moving its location: a new parameters in policy, it can override the value from cli. prefer to *int
, as we can distinguish "set to 0" or "not set".
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 value in CLI also can not set to 0 to disable it; so I'm ok with that to keep current behaviours. Please add a comments or TODO on this.
@@ -338,6 +338,11 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler | |||
} | |||
} | |||
} | |||
// issue: https://github.com/kubernetes/kubernetes/issues/43845 | |||
// for backward compatibility if user set the value in policy file, then we use it | |||
if policy.HardPodAffinitySymmetricWeight != 0 { |
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.
after changing it to *int
, check it against nil
.
plugin/pkg/scheduler/api/types.go
Outdated
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule | ||
// corresponding to every RequiredDuringScheduling affinity rule. | ||
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100. | ||
HardPodAffinitySymmetricWeight int |
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.
As I mentioned in issue, another option is to move it to PredicatePolicy
(per RequiredDuringScheduling
). But I don-t think it's required in this PR, so please add a TODO in the comments.
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 If we need to move it elsewhere, we should do it in this PR IMO. This is user facing and we don't want to deprecate it again and move it.
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.
Did not have requirements on HardPodAffinitySymmetricWeight per RequiredDuringScheduling
, so prefer to keep current behaviour :). And it's complex to achieve that.
plugin/pkg/scheduler/api/types.go
Outdated
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule | ||
// corresponding to every RequiredDuringScheduling affinity rule. | ||
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100. | ||
HardPodAffinitySymmetricWeight int |
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 If we need to move it elsewhere, we should do it in this PR IMO. This is user facing and we don't want to deprecate it again and move it.
plugin/pkg/scheduler/api/v1/types.go
Outdated
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule | ||
// corresponding to every RequiredDuringScheduling affinity rule. | ||
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 0-100. | ||
HardPodAffinitySymmetricWeight int |
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.
Wait! Are we changing the existing behavior of HardPodAffinitySymmetricWeight
or just its location? If the answer is the latter, then we shouldn't change the type.
@@ -338,6 +338,11 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler | |||
} | |||
} | |||
} | |||
// issue: https://github.com/kubernetes/kubernetes/issues/43845 | |||
// for backward compatibility if user set the value in policy file, then we use it |
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.
Policy is the new location of HardPodAffinitySymmetricWeight
, so backward compatibility is not addressed here, unless I am missing something.
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.
@bsalamat Backward scenario is user don't set the value in policy file, it will use the value from command line when create the scheduler. here the logic is if we set the value in policy file, we should use the value from new location.
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.
@wanghaoran1988 Backward compatibility applies if the user does not set it in the policy file and keep using the old way of providing the value, i.e., as a command line argument. The scenario that you described is the new way of providing the value. Nothing is wrong with your logic, just the comment is misleading.
We should warn users if they provide |
@bsalamat The MarkDeprecated will tell use the new location when they run the command. Yes, I will add test as I first comment said. |
adde2c0
to
19d4a5a
Compare
@k8s-bot ok to test |
@k8s-bot verify test this |
@@ -338,6 +338,12 @@ func (f *ConfigFactory) CreateFromConfig(policy schedulerapi.Policy) (*scheduler | |||
} | |||
} | |||
} | |||
// issue: https://github.com/kubernetes/kubernetes/issues/43845 |
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.
I would rewrite the whole comment to something like:
Providing HardPodAffinitySymmetricWeight in the policy config is the new and preferred way of providing the value. Give it higher precedence when it is provided.
@@ -119,6 +119,68 @@ func TestCreateFromConfig(t *testing.T) { | |||
} | |||
|
|||
factory.CreateFromConfig(policy) | |||
hpa := factory.GetHardPodAffinitySymmetricWeight() | |||
if hpa != v1.DefaultHardPodAffinitySymmetricWeight { | |||
t.Errorf("Wrong hardPodAffinitySymmetricWeight, ecpected: %d, get %d", v1.DefaultHardPodAffinitySymmetricWeight, hpa) |
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.
s/get %d/got: %d
factory.CreateFromConfig(policy) | ||
hpa := factory.GetHardPodAffinitySymmetricWeight() | ||
if hpa != 10 { | ||
t.Errorf("Wrong hardPodAffinitySymmetricWeight, ecpected: %d, get %d", 10, hpa) |
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.
same here
ffd1f73
to
0a15f6f
Compare
@k8s-bot non-cri e2e test this |
lgtm |
@timothysc @davidopp Any more comments on this? |
@wanghaoran1988 I agree with @gyliu513 about updating the scheduler config policy example file. |
@wanghaoran1988 Found another issue that you may want to fix when reviewing @bsalamat's PR #44805 : There is a integration test cases for policy config map https://github.com/kubernetes/kubernetes/blob/master/test/integration/scheduler/scheduler_test.go#L78-L153 , I think that you may want to create a new case named as |
@gyliu513 How about update the integration test instead of create a new one? |
+1, @wanghaoran1988 |
@@ -107,7 +107,8 @@ func TestSchedulerCreationFromConfigMap(t *testing.T) { | |||
"priorities" : [ | |||
{"name" : "PriorityOne", "weight" : 1}, | |||
{"name" : "PriorityTwo", "weight" : 5} | |||
] | |||
], | |||
"hardPodAffinitySymmetricWeight" : 10 | |||
}`, |
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.
You also need to verify the config is applied as others, such as schedPrioritizers
etc.
8f90706
to
5c886ae
Compare
@gyliu513 I decide not update the integration test in this pr, if you want to verify the value, you need export a lot variable or functions, an the unit test already covered this, if you guy still think we need that, I can do it in a follow up pr. |
@wanghaoran1988 I'm OK to handle this in another follow up PR. |
@k82cn @bsalamat @davidopp @timothysc I addressed the comments, but not sure where to go from here other than to keep fixing rebase issues. |
@@ -32,6 +32,10 @@ type Policy struct { | |||
Priorities []PriorityPolicy `json:"priorities"` | |||
// Holds the information to communicate with the extender(s) | |||
ExtenderConfigs []ExtenderConfig `json:"extenders"` | |||
// RequiredDuringScheduling affinity is not symmetric, but there is an implicit PreferredDuringScheduling affinity rule | |||
// corresponding to every RequiredDuringScheduling affinity rule. | |||
// HardPodAffinitySymmetricWeight represents the weight of implicit PreferredDuringScheduling affinity rule, in the range 1-100. |
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.
in the range 1-100
? Any check for it?
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.
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.
wow, great, thanks.
@@ -14,7 +14,7 @@ | |||
{"name" : "ServiceSpreadingPriority", "weight" : 1}, | |||
{"name" : "EqualPriority", "weight" : 1} | |||
], | |||
"extenders":[ | |||
"extenders":[ |
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.
Not yours, but I think we should add a blank space after :
.
"extenders": [
@wanghaoran1988 any update on this? I think this can catch 1.7 once the comments are addressed. |
@gyliu513 Updated |
/lgtm @wanghaoran1988 , thanks very much for your work :). |
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.
/lgtm
/lgtm Thanks, @wanghaoran1988! |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bsalamat, k82cn, wanghaoran1988 Assign the PR to them by writing
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
Automatic merge from submit-queue |
What this PR does / why we need it:
Move hardPodAffinitySymmetricWeight to scheduler policy config
Which issue this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close that issue when PR gets merged): fixes #43845Special notes for your reviewer:
If you like this, will add test later
Release note: