netalloc

package
v1.10.25 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Overview

Package netalloc allocates non-overlapping subnets from one platform pool, ledgered in the DB to survive restarts.

Index

Constants

This section is empty.

Variables

View Source
var ErrPoolExhausted = errors.New("network subnet pool exhausted")

ErrPoolExhausted means every pool subnet is taken; the operator must enlarge MIABI_NETWORK_POOL_CIDR.

Functions

func DeriveIPv6 added in v1.10.2

func DeriveIPv6(ulaPrefix, ipv4Subnet string) (string, error)

DeriveIPv6 derives a stable /64 from the IPv4 subnet (works on Engine 25); an empty prefix returns "" (daemon chooses).

Types

type NetworkProvisioner

type NetworkProvisioner interface {
	EnsureNetworkSpec(ctx context.Context, spec docker.NetworkSpec) (string, error)
	ListNetworks(ctx context.Context) ([]docker.Network, error)
}

Kept small so narrower service-level interfaces (e.g. the stack NetworkManager) satisfy it too.

type Service

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

Service allocates subnets from the configured pool.

func NewService

func NewService(repo *repositories.NetworkAllocationRepository, poolCIDR string, subnetPrefix int) (*Service, error)

config.validate catches bad pools first at boot, so the error here is defence in depth.

func (*Service) Allocate

func (s *Service) Allocate(dockerName string, nodeID uint, kind string) (*models.NetworkAllocation, error)

Allocate is idempotent per name; callers creating the Docker network should prefer EnsureManaged, which handles host overlaps.

func (*Service) Capacity

func (s *Service) Capacity() int

Capacity is the total number of subnets the pool can hold.

func (*Service) EnsureManaged

func (s *Service) EnsureManaged(ctx context.Context, dc NetworkProvisioner, spec docker.NetworkSpec, nodeID uint, kind string) (id, subnet string, err error)

func (*Service) ImportExisting

func (s *Service) ImportExisting(ctx context.Context, dc NetworkProvisioner, nodeID uint) error

ImportExisting reserves pool subnets already used by Docker networks on the node so none is handed out twice.

func (*Service) PublishStats

func (s *Service) PublishStats()

PublishStats is called after every mutation so /metrics stays current without a background loop.

func (*Service) Release

func (s *Service) Release(dockerName string) error

Release returns a removed network's subnet to the pool; idempotent.

func (*Service) SetIPv6 added in v1.10.2

func (s *Service) SetIPv6(enabled bool, ulaPrefix string)

func (*Service) Stats

func (s *Service) Stats() (used int, total int)

Stats reports pool utilization (used includes reserved rows).

Jump to

Keyboard shortcuts

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