From 8101b2eda099240288f55fec9e40725bc5e0a47c Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Tue, 18 Jun 2024 12:21:25 +0000 Subject: [PATCH 1/3] added condition for distributed logic --- pkg/gameserverallocations/find.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/gameserverallocations/find.go b/pkg/gameserverallocations/find.go index 3a0f23c8ba..4c234377b8 100644 --- a/pkg/gameserverallocations/find.go +++ b/pkg/gameserverallocations/find.go @@ -40,6 +40,9 @@ func findGameServerForAllocation(gsa *allocationv1.GameServerAllocation, list [] var loop func(list []*agonesv1.GameServer, f func(i int, gs *agonesv1.GameServer)) + // Determine if Priorities are set in the Fleet spec + prioritiesSet := len(gsa.Spec.Priorities) > 0 + // packed is forward looping, distributed is random looping switch gsa.Spec.Scheduling { case apis.Packed: @@ -51,7 +54,7 @@ func findGameServerForAllocation(gsa *allocationv1.GameServerAllocation, list [] case apis.Distributed: // randomised looping - make a list of indices, and then randomise them // as we don't want to change the order of the gameserver slice - if !runtime.FeatureEnabled(runtime.FeatureCountsAndLists) { + if !runtime.FeatureEnabled(runtime.FeatureCountsAndLists) || !prioritiesSet { l := len(list) indices := make([]int, l) for i := 0; i < l; i++ { From decda1d620384a79c3426fee65d797c3844b0791 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Mon, 24 Jun 2024 07:30:34 +0000 Subject: [PATCH 2/3] moved inside distributed --- pkg/gameserverallocations/find.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/gameserverallocations/find.go b/pkg/gameserverallocations/find.go index 4c234377b8..c1c1225994 100644 --- a/pkg/gameserverallocations/find.go +++ b/pkg/gameserverallocations/find.go @@ -40,9 +40,6 @@ func findGameServerForAllocation(gsa *allocationv1.GameServerAllocation, list [] var loop func(list []*agonesv1.GameServer, f func(i int, gs *agonesv1.GameServer)) - // Determine if Priorities are set in the Fleet spec - prioritiesSet := len(gsa.Spec.Priorities) > 0 - // packed is forward looping, distributed is random looping switch gsa.Spec.Scheduling { case apis.Packed: @@ -52,6 +49,9 @@ func findGameServerForAllocation(gsa *allocationv1.GameServerAllocation, list [] } } case apis.Distributed: + // Determine if Priorities are set in the Fleet spec + prioritiesSet := len(gsa.Spec.Priorities) > 0 + // randomised looping - make a list of indices, and then randomise them // as we don't want to change the order of the gameserver slice if !runtime.FeatureEnabled(runtime.FeatureCountsAndLists) || !prioritiesSet { From 38093a1610ace3fad7e4fe46ff8e199f885e7510 Mon Sep 17 00:00:00 2001 From: Ashutosh Singh Date: Sun, 14 Jul 2024 07:22:06 +0000 Subject: [PATCH 3/3] added the inline suggestion --- pkg/gameserverallocations/find.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/gameserverallocations/find.go b/pkg/gameserverallocations/find.go index c1c1225994..01ed9ec5da 100644 --- a/pkg/gameserverallocations/find.go +++ b/pkg/gameserverallocations/find.go @@ -49,12 +49,9 @@ func findGameServerForAllocation(gsa *allocationv1.GameServerAllocation, list [] } } case apis.Distributed: - // Determine if Priorities are set in the Fleet spec - prioritiesSet := len(gsa.Spec.Priorities) > 0 - // randomised looping - make a list of indices, and then randomise them // as we don't want to change the order of the gameserver slice - if !runtime.FeatureEnabled(runtime.FeatureCountsAndLists) || !prioritiesSet { + if !runtime.FeatureEnabled(runtime.FeatureCountsAndLists) || len(gsa.Spec.Priorities) == 0 { l := len(list) indices := make([]int, l) for i := 0; i < l; i++ {