network

package
v5.5.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package network is DEPRECATED and can be dropped once v29 is gone. The network package moved to the versioned controller packages and should further be maintained there. See also the TODO issue below.

https://github.com/giantswarm/giantswarm/issues/6439

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateSubnetMask

func CalculateSubnetMask(networkMask net.IPMask, n uint) (net.IPMask, error)

CalculateSubnetMask calculates new subnet mask to accommodate n subnets.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsInvalidParameter

func IsInvalidParameter(err error) bool

IsInvalidParameter asserts invalidParameterError.

func Split

func Split(network net.IPNet, n uint) ([]net.IPNet, error)

Split returns n subnets from network.

Types

type AllocationCallbacks

type AllocationCallbacks struct {
	// GetReservedNetworks implementation must return all networks that are
	// allocated on any given moment. Failing to do that will result in
	// overlapping allocations.
	GetReservedNetworks func(context.Context) ([]net.IPNet, error)

	// PersistAllocatedNetwork must mutate shared persistent state so that on
	// successful execution persistet network is visible when
	// GetReservedNetworks() is called.
	PersistAllocatedNetwork func(context.Context, net.IPNet) error
}

AllocationCallbacks holds function pointers for two methods that must be called inside a lock when allocating new network range.

type Allocator

type Allocator interface {
	// Allocate performs the subnet allocation from given fullRange for a CIDR
	// block with netSize. It requires function pointers to callbacks that are
	// used for getting currently reserved networks and persisting allocated
	// network. These are called within an single lock so given that callbacks
	// work correctly, this is concurrent safe within single process e.g. when
	// logic between multiple controllers are allocating networks from the same
	// pool.
	//
	// NOTE: This is NOT concurrent safe between distinct processes.
	//
	// This returns either allocated network or an error.
	Allocate(ctx context.Context, fullRange net.IPNet, netSize net.IPMask, callbacks AllocationCallbacks) (net.IPNet, error)
}

Allocator is an interface for IPAM implementation that manages network range and subnets for an installation.

func New

func New(config Config) (Allocator, error)

type Config

type Config struct {
	Locker locker.Interface
	Logger micrologger.Logger
}

Jump to

Keyboard shortcuts

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