datastore

package
v1.6.2 Latest Latest
Warning

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

Go to latest
Published: May 29, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// DuplicatedENIError is an error when caller tries to add an duplicate ENI to data store
	DuplicatedENIError = "data store: duplicate ENI"

	// IPAlreadyInStoreError is an error when caller tries to add an duplicate IP address to data store
	IPAlreadyInStoreError = "datastore: IP already in data store"

	// UnknownIPError is an error when caller tries to delete an IP which is unknown to data store
	UnknownIPError = "datastore: unknown IP"

	// IPInUseError is an error when caller tries to delete an IP where IP is still assigned to a Pod
	IPInUseError = "datastore: IP is used and can not be deleted"

	// ENIInUseError is an error when caller tries to delete an ENI where there are IP still assigned to a pod
	ENIInUseError = "datastore: ENI is used and can not be deleted"

	// UnknownENIError is an error when caller tries to access an ENI which is unknown to datastore
	UnknownENIError = "datastore: unknown ENI"
)

Variables

View Source
var ErrUnknownPod = errors.New("datastore: unknown pod")

ErrUnknownPod is an error when there is no pod in data store matching pod name, namespace, sandbox id

View Source
var ErrUnknownPodIP = errors.New("datastore: pod using unknown IP address")

ErrUnknownPodIP is an error where pod's IP address is not found in data store

Functions

This section is empty.

Types

type AddressInfo

type AddressInfo struct {
	Address        string
	Assigned       bool // true if it is assigned to a pod
	UnassignedTime time.Time
}

AddressInfo contains information about an IP, Exported fields will be marshaled for introspection.

type DataStore

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

DataStore contains node level ENI/IP

func NewDataStore

func NewDataStore(log logger.Logger) *DataStore

NewDataStore returns DataStore structure

func (*DataStore) AddENI

func (ds *DataStore) AddENI(eniID string, deviceNumber int, isPrimary bool) error

AddENI add ENI to data store

func (*DataStore) AddIPv4AddressToStore

func (ds *DataStore) AddIPv4AddressToStore(eniID string, ipv4 string) error

AddIPv4AddressToStore add an IP of an ENI to data store

func (*DataStore) AssignPodIPv4Address

func (ds *DataStore) AssignPodIPv4Address(k8sPod *k8sapi.K8SPodInfo) (ip string, deviceNumber int, err error)

AssignPodIPv4Address assigns an IPv4 address to pod It returns the assigned IPv4 address, device number, error

func (*DataStore) DelIPv4AddressFromStore

func (ds *DataStore) DelIPv4AddressFromStore(eniID string, ipv4 string, force bool) error

DelIPv4AddressFromStore delete an IP of ENI from datastore

func (*DataStore) GetENIIPPools

func (ds *DataStore) GetENIIPPools(eni string) (map[string]*AddressInfo, error)

GetENIIPPools returns eni's IP address list

func (*DataStore) GetENIInfos

func (ds *DataStore) GetENIInfos() *ENIInfos

GetENIInfos provides ENI IP information to introspection endpoint

func (*DataStore) GetENINeedsIP

func (ds *DataStore) GetENINeedsIP(maxIPperENI int, skipPrimary bool) *ENIIPPool

GetENINeedsIP finds an ENI in the datastore that needs more IP addresses allocated

func (*DataStore) GetENIs

func (ds *DataStore) GetENIs() int

GetENIs provides the number of ENI in the datastore

func (*DataStore) GetPodInfos

func (ds *DataStore) GetPodInfos() *map[string]PodIPInfo

GetPodInfos provides pod IP information to introspection endpoint

func (*DataStore) GetStats

func (ds *DataStore) GetStats() (int, int)

GetStats returns total number of IP addresses and number of assigned IP addresses

func (*DataStore) RemoveENIFromDataStore

func (ds *DataStore) RemoveENIFromDataStore(eni string, force bool) error

RemoveENIFromDataStore removes an ENI from the datastore. It return nil on success or an error.

func (*DataStore) RemoveUnusedENIFromStore

func (ds *DataStore) RemoveUnusedENIFromStore(warmIPTarget int, minimumIPTarget int) string

RemoveUnusedENIFromStore removes a deletable ENI from the data store. It returns the name of the ENI which has been removed from the data store and needs to be deleted, or empty string if no ENI could be removed.

func (*DataStore) UnassignPodIPv4Address

func (ds *DataStore) UnassignPodIPv4Address(k8sPod *k8sapi.K8SPodInfo) (ip string, deviceNumber int, err error)

UnassignPodIPv4Address a) find out the IP address based on PodName and PodNameSpace b) mark IP address as unassigned c) returns IP address, ENI's device number, error

type ENIIPPool

type ENIIPPool struct {

	// IsPrimary indicates whether ENI is a primary ENI
	IsPrimary bool
	ID        string
	// DeviceNumber is the device number of ENI (0 means the primary ENI)
	DeviceNumber int
	// AssignedIPv4Addresses is the number of IP addresses already been assigned
	AssignedIPv4Addresses int
	// IPv4Addresses shows whether each address is assigned, the key is IP address, which must
	// be in dot-decimal notation with no leading zeros and no whitespace(eg: "10.1.0.253")
	IPv4Addresses map[string]*AddressInfo
	// contains filtered or unexported fields
}

ENIIPPool contains ENI/IP Pool information. Exported fields will be marshaled for introspection.

type ENIInfos

type ENIInfos struct {
	// TotalIPs is the total number of IP addresses
	TotalIPs int
	// assigned is the number of IP addresses that has been assigned
	AssignedIPs int
	// ENIIPPools contains ENI IP pool information
	ENIIPPools map[string]ENIIPPool
}

ENIInfos contains ENI IP information

type PodIPInfo

type PodIPInfo struct {
	// IP is the IP address of pod
	IP string
	// DeviceNumber is the device number of the ENI
	DeviceNumber int
}

PodIPInfo contains pod's IP and the device number of the ENI

type PodInfos

type PodInfos map[string]PodIPInfo

PodInfos contains pods IP information which uses key name_namespace_sandbox

type PodKey

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

PodKey is used to locate pod IP

Jump to

Keyboard shortcuts

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