@@ -19,9 +19,7 @@ import (
1919 "crypto/tls"
2020 "crypto/x509"
2121 "fmt"
22- "math/rand"
2322 "net/http"
24- "strconv"
2523 "strings"
2624 "time"
2725
@@ -73,11 +71,6 @@ const (
7371 secretClientKeyName = "tls.key"
7472 secretCACertName = "ca.crt"
7573 allocatorPort = "443"
76-
77- // Instead of selecting the top one, controller selects a random one
78- // from the topNGameServerCount of Ready gameservers
79- // to reduce the contention while allocating gameservers.
80- topNGameServerDefaultCount = 100
8174)
8275
8376const (
@@ -109,7 +102,6 @@ type Allocator struct {
109102 recorder record.EventRecorder
110103 pendingRequests chan request
111104 readyGameServerCache * ReadyGameServerCache
112- topNGameServerCount int
113105 remoteAllocationCallback func (context.Context , string , grpc.DialOption , * pb.AllocationRequest ) (* pb.AllocationResponse , error )
114106 remoteAllocationTimeout time.Duration
115107 totalRemoteAllocationTimeout time.Duration
@@ -138,7 +130,6 @@ func NewAllocator(policyInformer multiclusterinformerv1.GameServerAllocationPoli
138130 secretLister : secretInformer .Lister (),
139131 secretSynced : secretInformer .Informer ().HasSynced ,
140132 readyGameServerCache : readyGameServerCache ,
141- topNGameServerCount : topNGameServerDefaultCount ,
142133 remoteAllocationTimeout : remoteAllocationTimeout ,
143134 totalRemoteAllocationTimeout : totalRemoteAllocationTimeout ,
144135 remoteAllocationCallback : func (ctx context.Context , endpoint string , dialOpts grpc.DialOption , request * pb.AllocationRequest ) (* pb.AllocationResponse , error ) {
@@ -607,24 +598,6 @@ func Retry(backoff wait.Backoff, fn func() error) error {
607598 return err
608599}
609600
610- // getRandomlySelectedGS selects a GS from the set of Gameservers randomly. This will reduce the contentions
611- func (c * Allocator ) getRandomlySelectedGS (gsa * allocationv1.GameServerAllocation , bestGSList []agonesv1.GameServer ) * agonesv1.GameServer {
612- seed , err := strconv .Atoi (gsa .ObjectMeta .ResourceVersion )
613- if err != nil {
614- seed = 1234567
615- }
616-
617- ln := c .topNGameServerCount
618- if ln > len (bestGSList ) {
619- ln = len (bestGSList )
620- }
621-
622- startIndex := len (bestGSList ) - ln
623- bestGSList = bestGSList [startIndex :]
624- index := rand .New (rand .NewSource (int64 (seed ))).Intn (ln )
625- return & bestGSList [index ]
626- }
627-
628601// newMetrics creates a new gsa latency recorder.
629602func (c * Allocator ) newMetrics (ctx context.Context ) * metrics {
630603 ctx , err := tag .New (ctx , latencyTags ... )
0 commit comments