Help us shape the future of Go! Take the 2026 Go Developer Survey

nodesubnet

package
v1.7.21 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Default minimum time between secondary IP fetches
	DefaultMinRefreshInterval = 4 * time.Second
	// Default maximum time between secondary IP fetches
	DefaultMaxRefreshInterval = 1024 * time.Second
)
View Source
const (
	// ID for fake NC that we create to store NodeSubnet IPS
	NodeSubnetNCID          = "55022629-3854-499b-7133-5e6887959f4ea" // md5sum of "NodeSubnetNC_IPv4"
	NodeSubnetNCVersion     = 0
	NodeSubnetHostVersion   = "0"
	NodeSubnetNCStatus      = v1alpha.NCUpdateSuccess
	NodeSubnetHostPrimaryIP = ""
)

Variables

View Source
var ErrRefreshSkipped = errors.New("refresh skipped due to throttling")

Functions

func CreateNodeSubnetNCRequest

func CreateNodeSubnetNCRequest(secondaryIPs []string) *cns.CreateNetworkContainerRequest

CreateNodeSubnetNCRequest generates a CreateNetworkContainerRequest that simply stores the static secondary IPs.

func ReconcileInitialCNSState

func ReconcileInitialCNSState(_ context.Context, ipamReconciler ipamReconciler, podInfoByIPProvider cns.PodInfoByIPProvider) (int, error)

Types

type IPConsumer

type IPConsumer interface {
	UpdateIPsForNodeSubnet([]netip.Addr) error
}

IPConsumer is an interface implemented by whoever consumes the secondary IPs fetched in nodesubnet

type IPFetcher

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

IPFetcher fetches secondary IPs from NMAgent at regular intervals. The interval will vary within the range of minRefreshInterval and maxRefreshInterval. When no diff is observed after a fetch, the interval doubles (subject to the maximum interval). When a diff is observed, the interval resets to the minimum.

func NewIPFetcher

func NewIPFetcher(
	client InterfaceRetriever,
	consumer IPConsumer,
	minInterval time.Duration,
	maxInterval time.Duration,
	logger refresh.Logger,
) *IPFetcher

NewIPFetcher creates a new IPFetcher. If minInterval is 0, it will default to 4 seconds. If maxInterval is 0, it will default to 1024 seconds (or minInterval, if it is higher).

func (*IPFetcher) ProcessInterfaces

func (c *IPFetcher) ProcessInterfaces(response nmagent.Interfaces) error

Fetch IPs from NMAgent and pass to the consumer

func (*IPFetcher) Start

func (c *IPFetcher) Start(ctx context.Context)

Start the IPFetcher.

type InterfaceRetriever

type InterfaceRetriever interface {
	GetInterfaceIPInfo(ctx context.Context) (nmagent.Interfaces, error)
}

InterfaceRetriever is an interface is implemented by the NMAgent Client, and also a mock client for testing.

Jump to

Keyboard shortcuts

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