Changing error for too few nodes (#899)
* changing error * change variable name Co-authored-by: Alex <33497058+bexsoft@users.noreply.github.com> Co-authored-by: Adam Stafford <adamstafford@Adams-MacBook-Pro.local> Co-authored-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
@@ -56,8 +56,8 @@ func registerNodesHandlers(api *operations.OperatorAPI) {
|
||||
|
||||
// getMaxAllocatableMemory get max allocatable memory given a desired number of nodes
|
||||
func getMaxAllocatableMemory(ctx context.Context, clientset v1.CoreV1Interface, numNodes int32) (*models.MaxAllocatableMemResponse, error) {
|
||||
if numNodes == 0 {
|
||||
return nil, errors.New("error NumNodes must be greated than 0")
|
||||
if numNodes < 4 {
|
||||
return nil, errors.New("error NumNodes must be at least 4")
|
||||
}
|
||||
|
||||
// get all nodes from cluster
|
||||
@@ -65,6 +65,18 @@ func getMaxAllocatableMemory(ctx context.Context, clientset v1.CoreV1Interface,
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(nodes.Items) < int(numNodes) {
|
||||
return nil, errTooFewNodes
|
||||
}
|
||||
activeNodes := 0
|
||||
for i := 0; i < len(nodes.Items); i++ {
|
||||
if !nodes.Items[i].Spec.Unschedulable {
|
||||
activeNodes++
|
||||
}
|
||||
}
|
||||
if activeNodes < int(numNodes) {
|
||||
return nil, errTooFewSchedulableNodes
|
||||
}
|
||||
|
||||
availableMemSizes := []int64{}
|
||||
OUTER:
|
||||
|
||||
Reference in New Issue
Block a user