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

Wrong calculation for queue deserved in proportion plugin #665

Closed
zionwu opened this issue Mar 27, 2019 · 1 comment
Closed

Wrong calculation for queue deserved in proportion plugin #665

zionwu opened this issue Mar 27, 2019 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@zionwu
Copy link
Contributor

zionwu commented Mar 27, 2019

Is this a BUG REPORT or FEATURE REQUEST?:
/kind bug

What happened:
The kube-batch crash with following error message:

panic: Resource is not sufficient to do operation: <cpu 408833.33, memory 5346978668544.00, GPU 0.00> sub <cpu 608000.00, memory 5153960755200.00, GPU 0.00> [recovered]
	panic: Resource is not sufficient to do operation: <cpu 408833.33, memory 5346978668544.00, GPU 0.00> sub <cpu 608000.00, memory 5153960755200.00, GPU 0.00>

goroutine 246 [running]:
github.com/kubernetes-sigs/kube-batch/vendor/k8s.io/apimachinery/pkg/util/runtime.HandleCrash(0x0, 0x0, 0x0)
	/Users/klaus/Workspace/kb_ws/src/github.com/kubernetes-sigs/kube-batch/vendor/k8s.io/apimachinery/pkg/util/runtime/runtime.go:58 +0x108
panic(0x111cb00, 0xc00102a870)
	/usr/local/go/src/runtime/panic.go:513 +0x1b9
github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api.(*Resource).Sub(0xc001003760, 0xc0010037e0, 0xc000564458)
	/Users/klaus/Workspace/kb_ws/src/github.com/kubernetes-sigs/kube-batch/pkg/scheduler/api/resource_info.go:108 +0x10e
github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/proportion.(*proportionPlugin).OnSessionOpen(0xc000f78360, 0xc00039a9c0)
	/Users/klaus/Workspace/kb_ws/src/github.com/kubernetes-sigs/kube-batch/pkg/scheduler/plugins/proportion/proportion.go:138 +0xefc
github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework.OpenSession(0x143e180, 0xc0002a01c0, 0xc000e4e280, 0x5, 0x8, 0x0)
	/Users/klaus/Workspace/kb_ws/src/github.com/kubernetes-sigs/kube-batch/pkg/scheduler/framework/framework.go:36 +0x275
github.com/kubernetes-sigs/kube-batch/pkg/scheduler.(*Scheduler).runOnce(0xc000395ce0)

line 138 in proportion.go(https://github.com/kubernetes-sigs/kube-batch/blob/master/pkg/scheduler/plugins/proportion/proportion.go#L138) cause this issue:

remaining.Sub(deserved)

However, deserved should always less then remaining, the root cause is the following line:

deserved.Add(attr.deserved)

deserved should not add attr.deserved . If the attr.deserved is not meet, next time it will increase then it is added to deserved again and remaining will subtract the same attr.deserverd twice.

We should change to calculate using the increment part:

queueDeserved := remaining.Clone().Multi(float64(attr.weight) / float64(totalWeight))
deserved.Add(queueDeserved)
@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Mar 27, 2019
@zionwu
Copy link
Contributor Author

zionwu commented Mar 28, 2019

Closed as fix is merged.

@zionwu zionwu closed this as completed Mar 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants