Package gameserverallocations handles management of allocating Ready GameServers via selectors



This section is empty.


View Source
var (
	// ErrNoGameServerReady is returned when there are no Ready GameServers
	// available
	ErrNoGameServerReady = errors.New("Could not find a Ready GameServer")
	// ErrConflictInGameServerSelection is returned when the candidate gameserver already allocated
	ErrConflictInGameServerSelection = errors.New("The Gameserver was already allocated")
	// ErrTotalTimeoutExceeded is used to signal that total retry timeout has been exceeded and no additional retries should be made
	ErrTotalTimeoutExceeded = status.Errorf(codes.DeadlineExceeded, "remote allocation total timeout exceeded")


func Retry

func Retry(backoff wait.Backoff, fn func() error) error

Retry retries fn based on backoff provided.


type Allocator

type Allocator struct {
	// contains filtered or unexported fields

Allocator handles game server allocation

func NewAllocator

func NewAllocator(policyInformer multiclusterinformerv1.GameServerAllocationPolicyInformer, secretInformer informercorev1.SecretInformer,
	kubeClient kubernetes.Interface, readyGameServerCache *ReadyGameServerCache, remoteAllocationTimeout time.Duration, totalRemoteAllocationTimeout time.Duration) *Allocator

NewAllocator creates an instance of Allocator

func (*Allocator) Allocate

func (c *Allocator) Allocate(gsa *allocationv1.GameServerAllocation, stop <-chan struct{}) (k8sruntime.Object, error)

Allocate CRDHandler for allocating a gameserver.

func (*Allocator) ListenAndAllocate

func (c *Allocator) ListenAndAllocate(updateWorkerCount int, stop <-chan struct{})

ListenAndAllocate is a blocking function that runs in a loop looking at c.requestBatches for batches of requests that are coming through.

func (*Allocator) Start

func (c *Allocator) Start(stop <-chan struct{}) error

Start initiates the listeners.

func (*Allocator) Sync

func (c *Allocator) Sync(stop <-chan struct{}) error

Sync waits for cache to sync

type Controller

type Controller struct {
	// contains filtered or unexported fields

Controller is a the GameServerAllocation controller

func NewController

func NewController(apiServer *apiserver.APIServer,
	health healthcheck.Handler,
	counter *gameservers.PerNodeCounter,
	kubeClient kubernetes.Interface,
	kubeInformerFactory informers.SharedInformerFactory,
	agonesClient versioned.Interface,
	agonesInformerFactory externalversions.SharedInformerFactory,
	remoteAllocationTimeout time.Duration,
	totalAllocationTimeout time.Duration,
) *Controller

NewController returns a controller for a GameServerAllocation

func (*Controller) Run

func (c *Controller) Run(_ int, stop <-chan struct{}) error

Run runs this controller. Will block until stop is closed. Ignores threadiness, as we only needs 1 worker for cache sync

type ReadyGameServerCache

type ReadyGameServerCache struct {
	// contains filtered or unexported fields

ReadyGameServerCache handles the gameserver sync operations for cache

func NewReadyGameServerCache

func NewReadyGameServerCache(informer informerv1.GameServerInformer, gameServerGetter getterv1.GameServersGetter, counter *gameservers.PerNodeCounter, health healthcheck.Handler) *ReadyGameServerCache

NewReadyGameServerCache creates a new instance of ReadyGameServerCache

func (*ReadyGameServerCache) AddToReadyGameServer

func (c *ReadyGameServerCache) AddToReadyGameServer(gs *agonesv1.GameServer)

AddToReadyGameServer adds a gameserver to the list of ready game server list

func (*ReadyGameServerCache) ListSortedReadyGameServers

func (c *ReadyGameServerCache) ListSortedReadyGameServers() []*agonesv1.GameServer

ListSortedReadyGameServers returns a list of the cache ready gameservers sorted by most allocated to least

func (*ReadyGameServerCache) PatchGameServerMetadata

func (c *ReadyGameServerCache) PatchGameServerMetadata(fam allocationv1.MetaPatch, gs *agonesv1.GameServer) (*agonesv1.GameServer, error)

PatchGameServerMetadata patches the input gameserver with allocation meta patch and returns the updated gameserver

func (*ReadyGameServerCache) RemoveFromReadyGameServer

func (c *ReadyGameServerCache) RemoveFromReadyGameServer(gs *agonesv1.GameServer) error

RemoveFromReadyGameServer removes a gameserver from the list of ready game server list

func (*ReadyGameServerCache) Resync

func (c *ReadyGameServerCache) Resync()

Resync enqueues an empty game server to be synced. Using queue helps avoiding multiple threads syncing at the same time.

func (*ReadyGameServerCache) Start

func (c *ReadyGameServerCache) Start(stop <-chan struct{}) error

Start prepares cache to start

func (*ReadyGameServerCache) Sync

func (c *ReadyGameServerCache) Sync(stop <-chan struct{}) error

Sync waits for cache to sync

func (*ReadyGameServerCache) SyncGameServers

func (c *ReadyGameServerCache) SyncGameServers(key string) error

SyncGameServers synchronises the GameServers to Gameserver cache. This is called when a failure happened during the allocation. This method will sync and make sure the cache is up to date.