Merge pull request #7786 from rainzm/scheduler/igselect

fix(scheduler): fix array out of bounds when sorting hosts
This commit is contained in:
yunion-ci-robot
2020-09-07 15:31:42 +08:00
committed by GitHub
@@ -98,7 +98,7 @@ func buildHosts(result *core.SchedResultItemList, groups map[string]*models.SGro
// sortHost sorts the host for guest that is the backup one of the high-availability guest
// if isBackup is true and the master one if isBackup is false.
func sortHosts(hosts []*sSchedResultItem, guestInfo *sGuestInfo, isBackup *bool) {
sortIndexi, sortIndexj := make([]int64, 4), make([]int64, 4)
sortIndexi, sortIndexj := make([]int64, 5), make([]int64, 5)
sort.Slice(hosts, func(i, j int) bool {
switch {
case isBackup == nil: