pool

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PoolStateLabel  = "allocation.cybericebox.com/state"
	LatestPoolLabel = "allocation.cybericebox.com/latest"
	PoolGroupLabel  = "allocation.cybericebox.com/group"

	PoolStateEmpty   = "empty"
	PoolStatePartial = "partial"
	PoolStateFull    = "full"

	// PoolTypeLabel carries semantic pool type (vni, vpn-clients, lab-subnets).
	PoolTypeLabel = "pool.cybericebox.com/type"

	// Semantic pool type values.
	PoolTypeVPNClients = "vpn-clients"
	PoolTypeLabSubnets = "lab-subnets"
	PoolTypeVNI        = "vni"
)
View Source
const CursorAnnotation = "allocation.cybericebox.com/cursor"

CursorAnnotation on a Pool remembers where a rotating allocator handed out last.

Variables

This section is empty.

Functions

func InitBitmap

func InitBitmap(size, offset uint) (string, uint)

InitBitmap initialises a pool's bitmap and returns (encodedBitmap, freeCount). Bit 0 is reserved when offset == 0 to avoid assigning the network-address index.

func ReleaseOwnedIndex added in v1.1.0

func ReleaseOwnedIndex(ctx context.Context, c client.Client, prefix, namespace string, size uint, lease Lease) error

func ValidateLease added in v1.1.0

func ValidateLease(ctx context.Context, c client.Reader, prefix, namespace string, size uint, lease Lease) error

Types

type Allocator

type Allocator interface {
	AllocateIndex(ctx context.Context) (uint, error)
	ReleaseIndex(ctx context.Context, index uint) error
}

func NewAllocator

func NewAllocator(c client.Client, poolNamePrefix, namespace string, poolSize uint) Allocator

func NewRotatingAllocator

func NewRotatingAllocator(c client.Client, poolNamePrefix, namespace string, poolSize uint) Allocator

NewRotatingAllocator is NewAllocator with indexes that are not reused until the pool has been walked (see allocator.rotate): the VNIs of the lab networks, where the same number meeting a new lab at once could inherit stale flows on a node.

type Lease added in v1.1.0

type Lease struct {
	Index             uint
	PoolUID, OwnerUID string
	Generation        int64
}

Lease is an immutable reservation epoch. Its UID survives caller/process restart; PoolUID also fences pool deletion/recreation with a reset counter.

func AllocateOwnedIndex added in v1.1.0

func AllocateOwnedIndex(ctx context.Context, c client.Client, prefix, namespace string, size uint, uid string) (*Lease, error)

func FindOwnerLease added in v1.1.0

func FindOwnerLease(ctx context.Context, c client.Reader, prefix, namespace, uid string) (*Lease, error)

func PinExistingIndex added in v1.1.0

func PinExistingIndex(ctx context.Context, c client.Client, prefix, namespace string, size, index uint, uid string) (*Lease, error)

PinExistingIndex upgrades a currently held legacy reservation. It never binds a clear bit or a differently owned lease; all subsequent releases are fenced.

Jump to

Keyboard shortcuts

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