mirror of https://github.com/docker/docs.git
cleanup index and reuse size vars
Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
This commit is contained in:
parent
558b1e3c52
commit
fd643ad079
|
@ -21,8 +21,7 @@ func (p *RandomPlacementStrategy) Initialize() error {
|
|||
// PlaceContainer is exported
|
||||
func (p *RandomPlacementStrategy) PlaceContainer(config *dockerclient.ContainerConfig, nodes []cluster.Node) (cluster.Node, error) {
|
||||
if size := len(nodes); size > 0 {
|
||||
index := rand.Intn(len(nodes))
|
||||
return nodes[index], nil
|
||||
return nodes[rand.Intn(size)], nil
|
||||
}
|
||||
|
||||
return nil, errors.New("No nodes running in the cluster")
|
||||
|
|
Loading…
Reference in New Issue