Merge pull request https://github.com/kubernetes/contrib/pull/1670 from mwielgus/random-node-pool

Cluster-autoscaler: pick one of the matching node groups at random
This commit is contained in:
Marcin Wielgus 2016-09-01 12:12:51 +02:00 committed by GitHub
commit cb9ceffe41
1 changed files with 3 additions and 1 deletions

View File

@ -18,6 +18,7 @@ package main
import (
"fmt"
"math/rand"
"reflect"
"time"
@ -181,7 +182,8 @@ func GetNodeInfosForGroups(nodes []*kube_api.Node, cloudProvider cloudprovider.C
// BestExpansionOption picks the best cluster expansion option.
func BestExpansionOption(expansionOptions []ExpansionOption) *ExpansionOption {
if len(expansionOptions) > 0 {
return &expansionOptions[0]
pos := rand.Int31n(int32(len(expansionOptions)))
return &expansionOptions[pos]
}
return nil
}