Documentation ¶
Overview ¶
Package idalloc is responsible for allocation of numeric identifiers in distributed manner, where each node in the cluster needs to be able to allocate an unique ID from the given pool for a given purpose identified by a string label, but once allocated, other nodes can not change / allocate a different ID for given purpose (label).
Index ¶
- Variables
- type API
- type Deps
- type IDAllocator
- func (a *IDAllocator) Close() error
- func (a *IDAllocator) GetOrAllocateID(poolName string, idLabel string) (id uint32, err error)
- func (a *IDAllocator) HandlesEvent(event controller.Event) bool
- func (a *IDAllocator) Init() (err error)
- func (a *IDAllocator) InitPool(name string, poolRange *idallocation.AllocationPool_Range) (err error)
- func (a *IDAllocator) ReleaseID(poolName string, idLabel string) (err error)
- func (a *IDAllocator) Resync(event controller.Event, kubeStateData controller.KubeStateData, ...) (err error)
- func (a *IDAllocator) Revert(event controller.Event) error
- func (a *IDAllocator) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
- type Option
Constants ¶
This section is empty.
Variables ¶
var DefaultPlugin = *NewPlugin()
DefaultPlugin is a default instance of IDAlloc plugin.
Functions ¶
This section is empty.
Types ¶
type API ¶
type API interface { // InitPool initializes ID allocation pool with given name and ID range. // If the pool already exists, returns success if the pool range matches with // existing one (and effectively does nothing), false otherwise. InitPool(name string, poolRange *idallocation.AllocationPool_Range) (err error) // GetOrAllocateID returns allocated ID in given pool for given label. If the ID was // not already allocated, allocates new available ID. GetOrAllocateID(poolName string, idLabel string) (id uint32, err error) // ReleaseID releases existing allocation for given pool and label. // NOOP if the allocation does not exist. ReleaseID(poolName string, idLabel string) (err error) }
API defines methods provided by the IDAllocator plugin for use by other plugins to query pod memif allocation info and release pod memif allocations.
type Deps ¶
type Deps struct { infra.PluginDeps ServiceLabel servicelabel.ReaderAPI ContivConf contivconf.API RemoteDB nodesync.KVDBWithAtomic }
Deps lists dependencies of the IDAllocator plugin.
type IDAllocator ¶
type IDAllocator struct { Deps // contains filtered or unexported fields }
IDAllocator plugin implements allocation of numeric identifiers in distributed manner.
func NewPlugin ¶
func NewPlugin(opts ...Option) *IDAllocator
NewPlugin creates a new Plugin with the provides Options
func (*IDAllocator) GetOrAllocateID ¶
func (a *IDAllocator) GetOrAllocateID(poolName string, idLabel string) (id uint32, err error)
GetOrAllocateID returns allocated ID in given pool for given label. If the ID was not already allocated, allocates new available ID.
func (*IDAllocator) HandlesEvent ¶
func (a *IDAllocator) HandlesEvent(event controller.Event) bool
HandlesEvent selects:
- Resync
- KubeStateChange for ID allocation db resource
func (*IDAllocator) Init ¶
func (a *IDAllocator) Init() (err error)
Init initializes plugin internals.
func (*IDAllocator) InitPool ¶
func (a *IDAllocator) InitPool(name string, poolRange *idallocation.AllocationPool_Range) (err error)
InitPool initializes ID allocation pool with given name and ID range. If the pool already exists, returns success if the pool range matches with existing one (and effectively does nothing), false otherwise.
func (*IDAllocator) ReleaseID ¶
func (a *IDAllocator) ReleaseID(poolName string, idLabel string) (err error)
ReleaseID releases existing allocation for given pool and label. NOOP if the pool or allocation does not exist.
func (*IDAllocator) Resync ¶
func (a *IDAllocator) Resync(event controller.Event, kubeStateData controller.KubeStateData, resyncCount int, txn controller.ResyncOperations) (err error)
Resync resynchronizes ID Allocator.
func (*IDAllocator) Revert ¶
func (a *IDAllocator) Revert(event controller.Event) error
Revert is NOOP - never called.
func (*IDAllocator) Update ¶
func (a *IDAllocator) Update(event controller.Event, txn controller.UpdateOperations) (changeDescription string, err error)
Update handles ID allocation db change events.