Skip to content

Commit

Permalink
Use all schedulable hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
chez-shanpu committed Jun 1, 2023
1 parent a366016 commit a171bd2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 79 deletions.
20 changes: 1 addition & 19 deletions server/pkg/api/server_add_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ func schedule(targets []targetHost, limitOverCommit uint64) (*targetHost, error)
return nil, ErrNoValidHost
}

minTargets := getMinTargets(schedulableTargets)

return &minTargets[rand.Intn(len(minTargets))], nil
return &schedulableTargets[rand.Intn(len(schedulableTargets))], nil
}

// parseAlias parse user input
Expand Down Expand Up @@ -259,19 +257,3 @@ func parseAlias(input string) (*api.InstanceSource, error) {
Alias: input,
}, nil
}

func getMinTargets(hosts []targetHost) []targetHost {
var minTargets []targetHost
// use lowest over-commit instance
// if there is more than one the lowest ones, it picks up from them randomly
minTargetOverCommit := hosts[0].percentOverCommit
for _, t := range hosts {
if minTargetOverCommit > t.percentOverCommit {
minTargetOverCommit = t.percentOverCommit
minTargets = []targetHost{t}
} else if minTargetOverCommit == t.percentOverCommit {
minTargets = append(minTargets, t)
}
}
return minTargets
}
60 changes: 0 additions & 60 deletions server/pkg/api/server_add_instance_test.go

This file was deleted.

0 comments on commit a171bd2

Please sign in to comment.