dindmanager

package
v0.0.0-...-9c0345f Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateUUIDv4

func GenerateUUIDv4() (string, error)

func InitSubnetPool

func InitSubnetPool(parentCIDRs []string) ([]string, error)

InitSubnetPool expands a list of parent CIDRs (e.g. ["192.168.0.0/16", "10.12.0.0/16"]) into an ordered slice of allocatable /24 subnets. Supported parent prefix lengths: /8, /16, /24. Returns an empty slice (no error) when parentCIDRs is nil/empty.

Types

type DindManager

type DindManager struct {
	DindList        []DindSpecs
	Ctx             context.Context
	FPGAEnabled     bool
	XilinxToolsPath string

	// Subnet pool: pre-generated /24 subnets from the parent CIDRs in config.
	// Protected by mu because container creation/deletion can happen concurrently.
	SubnetPool []string

	InitialPoolSz int // total subnets at startup, used for logging
	// contains filtered or unexported fields
}

func (*DindManager) BuildDindContainers

func (a *DindManager) BuildDindContainers(nDindContainer int8) error

func (*DindManager) ClaimAvailableDind

func (a *DindManager) ClaimAvailableDind(podUID string) (string, error)

ClaimAvailableDind atomically finds an available DIND container, marks it unavailable, and records the pod UID against it — all under a single lock. Doing this in one step (instead of GetAvailableDind + SetDindUnavailable + SetPodUIDToDind) prevents two concurrent creates from grabbing the same container, and guarantees the DIND is findable by pod UID for cleanup the moment it is claimed, closing the window where a failure would orphan it.

func (*DindManager) CleanDindContainers

func (a *DindManager) CleanDindContainers() error

func (*DindManager) GetAvailableDind

func (a *DindManager) GetAvailableDind() (string, error)

func (*DindManager) GetDindFromPodUID

func (a *DindManager) GetDindFromPodUID(podUID string) (DindSpecs, error)

func (*DindManager) PrintDindList

func (a *DindManager) PrintDindList() error

func (*DindManager) ReapOrphanNetworks

func (a *DindManager) ReapOrphanNetworks()

ReapOrphanNetworks removes DIND bridge networks that have no attached container. A create that fails after its network is created leaves such a network behind; because it still holds its /24 subnet, a later create drawing the same subnet from the pool fails with an address-overlap error. Removing only unattached networks is safe: Docker refuses to remove a network still in use by a live DIND container, so those are skipped. The build-in-flight guard avoids racing a network that was just created but whose container has not yet attached.

func (*DindManager) RemoveDindFromList

func (a *DindManager) RemoveDindFromList(PodUID string) error

RemoveDindFromList removes the DinD entry associated with PodUID from the in-memory list, tears down its Docker network, and returns its subnet to the pool so it can be reused by future containers.

func (*DindManager) SetDindAvailable

func (a *DindManager) SetDindAvailable(PodUID string) error

func (*DindManager) SetDindUnavailable

func (a *DindManager) SetDindUnavailable(dindID string) error

func (*DindManager) SetPodUIDToDind

func (a *DindManager) SetPodUIDToDind(dindID string, podUID string) error

type DindManagerInterface

type DindManagerInterface interface {
	CleanDindContainers() error
	BuildDindContainers(nDindContainer int8) error
	PrintDindList() error
	GetAvailableDind() (string, error)
	ClaimAvailableDind(podUID string) (string, error)
	SetDindUnavailable(dindID string) error
	RemoveDindFromList(PodUID string) error
	SetPodUIDToDind(dindID string, podUID string) error
	GetDindFromPodUID(podUID string) (DindSpecs, error)
	SetDindAvailable(PodUID string) error
	ReapOrphanNetworks()
}

type DindSpecs

type DindSpecs struct {
	DindID          string
	PodUID          string
	DindNetworkID   string
	AllocatedSubnet string // empty if no subnet pool was configured
	Available       bool
}

Jump to

Keyboard shortcuts

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