fix potential panic for node resource plugin

This commit is contained in:
yuzhiquan
2021-05-08 18:03:24 +08:00
parent 3dd0597843
commit 2b6af46624
4 changed files with 20 additions and 0 deletions

View File

@@ -138,6 +138,13 @@ func TestNodeResourcesLeastAllocated(t *testing.T) {
expectedList: []framework.NodeScore{{Name: "machine1", Score: 37}, {Name: "machine2", Score: 50}},
name: "nothing scheduled, resources requested, differently sized machines",
},
{
pod: &v1.Pod{Spec: cpuAndMemory},
nodes: []*v1.Node{makeNode("machine1", 4000, 10000), makeNode("machine2", 6000, 10000)},
args: config.NodeResourcesLeastAllocatedArgs{Resources: []config.ResourceSpec{}},
expectedList: []framework.NodeScore{{Name: "machine1", Score: 0}, {Name: "machine2", Score: 0}},
name: "Resources not set, nothing scheduled, resources requested, differently sized machines",
},
{
// Node1 scores on 0-MaxNodeScore scale
// CPU Score: ((4000 - 0) * MaxNodeScore) / 4000 = MaxNodeScore