Skip to content

Commit

Permalink
allow cpu prior oversell
Browse files Browse the repository at this point in the history
  • Loading branch information
CMGS committed Oct 24, 2017
1 parent 23e3e5c commit 8fffc52
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
8 changes: 3 additions & 5 deletions scheduler/complex/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ func newHost(cpuInfo types.CPUMap, share int64) *host {
fragment: types.CPUMap{},
}
for no, pieces := range cpuInfo {
if pieces == share {
result.full[no] = pieces
if pieces >= share {
result.full[no] = share
} else {
result.fragment[no] = pieces
}
Expand Down Expand Up @@ -175,9 +175,7 @@ func (h *host) getFullResult(full int64) types.CPUMap {
return result
}

func cpuPriorPlan(cpu float64, nodesInfo []types.NodeInfo, need int, maxShareCore, coreShare int64) (
int, []types.NodeInfo, map[string][]types.CPUMap) {

func cpuPriorPlan(cpu float64, nodesInfo []types.NodeInfo, need int, maxShareCore, coreShare int64) (int, []types.NodeInfo, map[string][]types.CPUMap) {
var nodeContainer = map[string][]types.CPUMap{}
var host *host
var plan []types.CPUMap
Expand Down
19 changes: 17 additions & 2 deletions scheduler/complex/potassium_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,9 +250,8 @@ func TestComplexNodes(t *testing.T) {
t.Fatalf("Create Potassim error: %v", merr)
}

nodes := getNodesInfo()
k, _ = New(coreCfg)
// test1
nodes := getNodesInfo()
res1, changed1, err := k.SelectCPUNodes(nodes, 1.7, 7)
if err != nil {
t.Fatalf("sth wrong")
Expand Down Expand Up @@ -297,6 +296,22 @@ func TestComplexNodes(t *testing.T) {
assert.Equal(t, err.Error(), "quota must positive")
}

func TestCPUOverSell(t *testing.T) {
coreCfg := newConfig()
coreCfg.Scheduler.ShareBase = 5
k, err := New(coreCfg)
if err != nil {
t.Fatalf("Create Potassim error: %v", err)
}

//test1
nodes := getNodesInfo()
_, _, err = k.SelectCPUNodes(nodes, 1.7, 3)
assert.NoError(t, err)

//TODO 增加其他测试吧,这里应该是没问题的
}

func getEvenPlanNodes() []types.NodeInfo {
return []types.NodeInfo{
types.NodeInfo{
Expand Down

0 comments on commit 8fffc52

Please sign in to comment.