gameserverallocations

package
v1.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2021 License: Apache-2.0 Imports: 59 Imported by: 1

Documentation

Overview

Package gameserverallocations handles management of allocating Ready GameServers via selectors

Index

Constants

This section is empty.

Variables

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")
)

Functions

func Retry added in v0.9.0

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

Retry retries fn based on backoff provided.

Types

type Allocator added in v1.0.0

type Allocator struct {
	// contains filtered or unexported fields
}

Allocator handles game server allocation

func NewAllocator added in v1.0.0

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 added in v1.0.0

Allocate CRDHandler for allocating a gameserver.

func (*Allocator) ListenAndAllocate added in v1.0.0

func (c *Allocator) ListenAndAllocate(ctx context.Context, updateWorkerCount int)

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 added in v1.0.0

func (c *Allocator) Start(ctx context.Context) error

Start initiates the listeners.

func (*Allocator) Sync added in v1.0.0

func (c *Allocator) Sync(ctx context.Context) 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(ctx context.Context, _ int) error

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

type ReadyGameServerCache added in v1.0.0

type ReadyGameServerCache struct {
	// contains filtered or unexported fields
}

ReadyGameServerCache handles the gameserver sync operations for cache

func NewReadyGameServerCache added in v1.0.0

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 added in v1.0.0

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

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

func (*ReadyGameServerCache) ListSortedReadyGameServers added in v1.0.0

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

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

func (*ReadyGameServerCache) PatchGameServerMetadata added in v1.0.0

func (c *ReadyGameServerCache) PatchGameServerMetadata(ctx context.Context, 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 added in v1.0.0

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

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

func (*ReadyGameServerCache) Resync added in v1.0.0

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 added in v1.0.0

func (c *ReadyGameServerCache) Start(ctx context.Context) error

Start prepares cache to start

func (*ReadyGameServerCache) Sync added in v1.0.0

Sync waits for cache to sync

func (*ReadyGameServerCache) SyncGameServers added in v1.0.0

func (c *ReadyGameServerCache) SyncGameServers(ctx context.Context, 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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL