Skip to content
This repository has been archived by the owner on May 25, 2023. It is now read-only.

Fix wrong caculation for deserved in proportion plugin #666

Merged
merged 1 commit into from
Mar 27, 2019

Conversation

zionwu
Copy link
Contributor

@zionwu zionwu commented Mar 27, 2019

Fix issue #665

@k8s-ci-robot
Copy link
Contributor

Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA.

It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please sign in with your organization's credentials at https://identity.linuxfoundation.org/projects/cncf to be authorized.
  • If you have done the above and are still having issues with the CLA being reported as unsigned, please email the CNCF helpdesk: [email protected]

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: no Indicates the PR's author has not signed the CNCF CLA. label Mar 27, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 27, 2019
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Mar 27, 2019
@@ -134,7 +135,7 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
glog.V(4).Infof("The attributes of queue <%s> in proportion: deserved <%v>, allocate <%v>, request <%v>, share <%0.2f>",
attr.name, attr.deserved, attr.allocated, attr.request, attr.share)

deserved.Add(attr.deserved)
deserved.Add(queueDeserved)
Copy link
Contributor

Choose a reason for hiding this comment

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

If !attr.deserved.LessEqual(attr.request), queueDeserved need be changed to attr.deserved increased value.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I did not get it. Could you explain a bit more?

I think the queueDeserved is already the increased value. In the for loop we add it to attr.deserved and deserved. After the for loop, we calculate the remaining by subtracting deserved

Copy link
Contributor

Choose a reason for hiding this comment

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

Suppose that queueDeserved is {cpu: 2, mem: 2G}, attr.deserved is {cpu: 1, mem: 1G} and attr.request is {cpu: 2, mem: 2G}, attr.deserved will be {cpu: 3, mem: 3G} after attr.deserved.Add(queueDeserved)(line 128). Then attr.deserved will be {cpu: 2, mem: 2G} after attr.deserved = helpers.Min(attr.deserved, attr.request)(line 130). So attr.deserved's increased value is actually {cpu: 1, mem: 1G}, and we just need add {cpu: 1, mem: 1G} instead of {cpu: 2, mem: 2G} to deserved.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

got it, thanks. Let me update it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! You code works. Just give some suggestion.

@hex108
Copy link
Contributor

hex108 commented Mar 27, 2019

@zionwu Thanks for the patch! Could you please help add a test for it?

@@ -124,17 +124,20 @@ func (pp *proportionPlugin) OnSessionOpen(ssn *framework.Session) {
continue
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Add: oldDeserved = attr.deserved.Clone()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

}
pp.updateShare(attr)

glog.V(4).Infof("The attributes of queue <%s> in proportion: deserved <%v>, allocate <%v>, request <%v>, share <%0.2f>",
attr.name, attr.deserved, attr.allocated, attr.request, attr.share)

deserved.Add(attr.deserved)
Copy link
Contributor

Choose a reason for hiding this comment

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

Changed to: deserved.Add(attr.deserved.Clone().sub(oldDeserved))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated

@hex108
Copy link
Contributor

hex108 commented Mar 27, 2019

lgtm except missing tests...

/assign @k82cn

@hex108
Copy link
Contributor

hex108 commented Mar 27, 2019

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 27, 2019
@k82cn
Copy link
Contributor

k82cn commented Mar 27, 2019

/approve

@k8s-ci-robot
Copy link
Contributor

[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 /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 Mar 27, 2019
@k8s-ci-robot k8s-ci-robot merged commit 6706f58 into kubernetes-retired:master Mar 27, 2019
k8s-ci-robot added a commit that referenced this pull request Mar 29, 2019
…#642-#638-#645-#647-#651-#652-#655-#658-#649-#660-#666-#671-#673-upstream-release-0.4

Automated cherry pick of #643: Return err in Allocate if any error occurs #642: Add event when task is scheduled #638: Take init containers into account when getting pod resource #645: Order task by CreationTimestamp first, then by UID #647: In allocate, skip adding Job if its queue is not found #651: Return err in functions of session.go if any error occurs #652: Change run option SchedulePeriod's type to make it clear #655: Do graceful eviction using default policy #658: Address helm install error in tutorial.md #649: Preempt lowest priority task first #660: Fix sub exception in reclaim and preempt #666: Fix wrong caculation for deserved in proportion plugin #671: Change base image to alphine to reduce image size #673: Do not create PodGroup and Job for task whose scheduler is
kevin-wangzefeng pushed a commit to kevin-wangzefeng/scheduler that referenced this pull request Jun 28, 2019
Fix wrong caculation for deserved in proportion plugin
kevin-wangzefeng pushed a commit to kevin-wangzefeng/scheduler that referenced this pull request Jun 28, 2019
Fix wrong caculation for deserved in proportion plugin
kevin-wangzefeng pushed a commit to kevin-wangzefeng/scheduler that referenced this pull request Jun 28, 2019
Fix wrong caculation for deserved in proportion plugin
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. lgtm Indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants