-
Notifications
You must be signed in to change notification settings - Fork 264
Fix wrong calculation for queue deserved in proportion plugin #730
Conversation
is it possible to add an e2e test for that? |
4f3280c
to
6454cc7
Compare
Let me spend some time to see if it is possible to add e2e test. |
ae41442
to
3153f5e
Compare
52c3b9b
to
3f3dc14
Compare
5b3e663
to
4a26249
Compare
ed91b62
to
f4a8ce0
Compare
7f28df9
to
eb50461
Compare
@k82cn, I have added the e2e test "Proportion". Without my fix, the test will fail. You can verify at this CI Test: https://travis-ci.org/kubernetes-sigs/kube-batch/builds/535261793?utm_source=github_status&utm_medium=notification With my fix, the test can pass, which you can check the latest CI result. |
@@ -125,20 +129,26 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) { | |||
|
|||
oldDeserved := attr.deserved.Clone() | |||
attr.deserved.Add(remaining.Clone().Multi(float64(attr.weight) / float64(totalWeight))) | |||
if !attr.deserved.LessEqual(attr.request) { | |||
|
|||
if attr.request.Less(attr.deserved) { |
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 has already been some problems caused by Less
and LessEqual
. The problems will be solved If the type MilliCPU
, Memory
and values of ScalarResources
change from float64
to resource.Quantity
or int64
.
@k82cn What is your option?
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 problems will be solved If the type MilliCPU, Memory and values of ScalarResources change from float64 to resource.Quantity or int64.
Do you mean if we change to int64, this fix is not necessary?
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 think so, because it is caused by LessEqual
is not <=
actually.
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.
LessEqual is not <= actually.
Can you share some case for that?
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 my opinion, this issue still exist even with resource.Quantity or int64.
The problem is that Resource is consist of MilliCPU, Memory and ScalarResources, and LessEqual
requires all 3 members to be lessEqual:
func (r *Resource) LessEqual(rr *Resource) bool {
isLess := (r.MilliCPU < rr.MilliCPU || math.Abs(rr.MilliCPU-r.MilliCPU) < minMilliCPU) &&
(r.Memory < rr.Memory || math.Abs(rr.Memory-r.Memory) < minMemory)
if !isLess {
return false
}
if r.ScalarResources == nil {
return true
}
for rName, rQuant := range r.ScalarResources {
if rr.ScalarResources == nil {
return false
}
rrQuant := rr.ScalarResources[rName]
if !(rQuant < rrQuant || math.Abs(rrQuant-rQuant) < minMilliScalarResources) {
return false
}
}
return true
}
!attr.deserved.LessEqual(attr.request)
is true when only one member of attr.deserved is larger than attr.request. But we need all 3 members of attr.deserved larger than attr.request. So we should always use attr.request.Less(attr.deserved)
no matter what type of the 3 member is.
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.
Agree with @zionwu , the error is because we use attr.request.LessEqual(attr.deserved)
but we should use attr.request.Less(attr.deserved)
.
if remaining.IsEmpty() { | ||
glog.V(4).Infof("exiting when remaining is empty: <%v>", remaining) |
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/exiting/Exiting/
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.
Updated.
LGTM overall, thanks 👍 |
/lgtm for this PR. |
@k82cn Could you approve this PR? Thanks. |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: k82cn, zionwu 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 |
What this PR does / why we need it:
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 #729