cleanup index and reuse size vars

Signed-off-by: Chanwit Kaewkasi <chanwit@gmail.com>
This commit is contained in:
Chanwit Kaewkasi 2015-04-02 13:54:39 +07:00
parent 558b1e3c52
commit fd643ad079
1 changed files with 1 additions and 2 deletions

View File

@ -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")