Move resource-based priority functions to their Score plugins

This commit is contained in:
notpad
2019-12-31 23:50:11 +08:00
parent f7e9a7c194
commit 7f79516705
20 changed files with 830 additions and 2031 deletions

View File

@@ -37,3 +37,19 @@ func makeNode(node string, milliCPU, memory int64) *v1.Node {
},
}
}
func makeNodeWithExtendedResource(node string, milliCPU, memory int64, extendedResource map[string]int64) *v1.Node {
resourceList := make(map[v1.ResourceName]resource.Quantity)
for res, quantity := range extendedResource {
resourceList[v1.ResourceName(res)] = *resource.NewQuantity(quantity, resource.DecimalSI)
}
resourceList[v1.ResourceCPU] = *resource.NewMilliQuantity(milliCPU, resource.DecimalSI)
resourceList[v1.ResourceMemory] = *resource.NewQuantity(memory, resource.BinarySI)
return &v1.Node{
ObjectMeta: metav1.ObjectMeta{Name: node},
Status: v1.NodeStatus{
Capacity: resourceList,
Allocatable: resourceList,
},
}
}