eni

package
v1.13.2 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResourceTypeLocalIP = 1 << iota
	ResourceTypeVeth
	ResourceTypeRemoteIP
	ResourceTypeRDMA
)
View Source
const (
	LocalIPTypeERDMA = "ERDMA"
)

Variables

This section is empty.

Functions

func Split added in v1.13.2

func Split[T any](arr []T, index int) ([]T, []T)

Types

type AllocRequest

type AllocRequest struct {
	ResourceRequests []ResourceRequest
}

AllocRequest represent a bunch of resource must be met.

type AllocResp

type AllocResp struct {
	Err error

	NetworkConfigs NetworkResources
}

type AllocatingRequests added in v1.13.2

type AllocatingRequests []*LocalIPRequest

func (*AllocatingRequests) Len added in v1.13.2

func (a *AllocatingRequests) Len() int

Len return the valid slice size

type ByPriority

type ByPriority []NetworkInterface

func (ByPriority) Len

func (n ByPriority) Len() int

func (ByPriority) Less

func (n ByPriority) Less(i, j int) bool

func (ByPriority) Swap

func (n ByPriority) Swap(i, j int)

type CRDV2 added in v1.9.6

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

func NewCRDV2 added in v1.9.6

func NewCRDV2(nodeName, namespace string) *CRDV2

func (*CRDV2) Allocate added in v1.9.6

func (r *CRDV2) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*CRDV2) Dispose added in v1.9.6

func (r *CRDV2) Dispose(n int) int

func (*CRDV2) Priority added in v1.9.6

func (r *CRDV2) Priority() int

func (*CRDV2) Release added in v1.9.6

func (r *CRDV2) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*CRDV2) Run added in v1.9.6

func (r *CRDV2) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

type Condition

type Condition struct {
	ConditionType ConditionType
	Reason        string
	Last          time.Time
}

type ConditionType

type ConditionType int
const (
	Full ConditionType = iota
	ResourceTypeMismatch
	NetworkInterfaceMismatch
	InsufficientVSwitchIP
)

func (ConditionType) String

func (i ConditionType) String() string

type IP

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

func NewIP

func NewIP(ip netip.Addr, primary bool) *IP

func NewValidIP

func NewValidIP(ip netip.Addr, primary bool) *IP

func (*IP) Allocatable

func (ip *IP) Allocatable() bool

func (*IP) Allocate

func (ip *IP) Allocate(podID string)

func (*IP) Deleting

func (ip *IP) Deleting() bool

func (*IP) Dispose

func (ip *IP) Dispose()

func (*IP) InUse

func (ip *IP) InUse() bool

func (*IP) Primary

func (ip *IP) Primary() bool

func (*IP) Release

func (ip *IP) Release(podID string)

func (*IP) SetInvalid

func (ip *IP) SetInvalid()

func (*IP) String

func (ip *IP) String() string

func (*IP) Valid

func (ip *IP) Valid() bool

type Local

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

func NewLocal

func NewLocal(eni *daemon.ENI, eniType string, factory factory.Factory, poolConfig *types.PoolConfig) *Local

func (*Local) Allocate

func (l *Local) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Local) Dispose

func (l *Local) Dispose(n int) int

func (*Local) Priority

func (l *Local) Priority() int

Priority for local resource only

func (*Local) Release

func (l *Local) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

Release take the cni Del request and release resource to pool

func (*Local) Run

func (l *Local) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

Run initialize the local eni

func (*Local) Status

func (l *Local) Status() Status

func (*Local) Usage

func (l *Local) Usage() (int, int, error)

type LocalIPRequest

type LocalIPRequest struct {
	NetworkInterfaceID string
	LocalIPType        string
	IPv4               netip.Addr
	IPv6               netip.Addr

	NoCache bool // do not use cached ip
	// contains filtered or unexported fields
}

func NewLocalIPRequest added in v1.13.2

func NewLocalIPRequest() *LocalIPRequest

func (*LocalIPRequest) ResourceType

func (l *LocalIPRequest) ResourceType() ResourceType

type LocalIPResource

type LocalIPResource struct {
	PodID string

	ENI daemon.ENI

	IP types.IPSet2
}

func (*LocalIPResource) ResourceType

func (l *LocalIPResource) ResourceType() ResourceType

func (*LocalIPResource) ToRPC

func (l *LocalIPResource) ToRPC() []*rpc.NetConf

func (*LocalIPResource) ToStore

func (l *LocalIPResource) ToStore() []daemon.ResourceItem

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewManager

func NewManager(minIdles, maxIdles, total int, syncPeriod time.Duration, networkInterfaces []NetworkInterface, selectionPolicy types.EniSelectionPolicy, k8s k8s.Kubernetes) *Manager

func (*Manager) Allocate

func (m *Manager) Allocate(ctx context.Context, cni *daemon.CNI, req *AllocRequest) (NetworkResources, error)

Allocate find the resource manager and send the request to it. Caller should roll back the allocated resource if any error happen.

func (*Manager) Release

func (m *Manager) Release(ctx context.Context, cni *daemon.CNI, req *ReleaseRequest) error

Release find the resource manager and send the request to it.

func (*Manager) Run

func (m *Manager) Run(ctx context.Context, wg *sync.WaitGroup, podResources []daemon.PodResources) error

func (*Manager) Status

func (m *Manager) Status() []Status

type NetworkInterface

type NetworkInterface interface {
	Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)
	Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)
	Priority() int
	Dispose(n int) int
	Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error
}

type NetworkResource

type NetworkResource interface {
	ResourceType() ResourceType

	ToRPC() []*rpc.NetConf

	ToStore() []daemon.ResourceItem
}

type NetworkResources

type NetworkResources []NetworkResource

type NodeCondition

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

func (*NodeCondition) Run

func (n *NodeCondition) Run()

func (*NodeCondition) SetIPExhaustive

func (n *NodeCondition) SetIPExhaustive()

func (*NodeCondition) UnsetIPExhaustive

func (n *NodeCondition) UnsetIPExhaustive()

type NodeConditionHandler

type NodeConditionHandler func(status corev1.ConditionStatus, reason, message string) error

type ReleaseRequest

type ReleaseRequest struct {
	NetworkResources []NetworkResource
}

type Remote

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

func NewRemote

func NewRemote(client client.Client, trunkENI *daemon.ENI) *Remote

func (*Remote) Allocate

func (r *Remote) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Remote) Dispose

func (r *Remote) Dispose(n int) int

func (*Remote) Priority

func (r *Remote) Priority() int

func (*Remote) Release

func (r *Remote) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*Remote) Run

func (r *Remote) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

type RemoteIPRequest

type RemoteIPRequest struct{}

func (*RemoteIPRequest) ResourceType

func (l *RemoteIPRequest) ResourceType() ResourceType

type RemoteIPResource

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

func (*RemoteIPResource) ResourceType

func (l *RemoteIPResource) ResourceType() ResourceType

func (*RemoteIPResource) ToRPC

func (l *RemoteIPResource) ToRPC() []*rpc.NetConf

func (*RemoteIPResource) ToStore

func (l *RemoteIPResource) ToStore() []daemon.ResourceItem

type ReportStatus

type ReportStatus interface {
	Status() Status
}

type ResourceRequest

type ResourceRequest interface {
	ResourceType() ResourceType
}

type ResourceType

type ResourceType int

type Set

type Set map[netip.Addr]*IP

func (Set) Add

func (s Set) Add(ip *IP)

func (Set) Allocatable

func (s Set) Allocatable() []*IP

func (Set) ByPodID

func (s Set) ByPodID(podID string) *IP

func (Set) Delete

func (s Set) Delete(ip ...netip.Addr)

func (Set) Deleting

func (s Set) Deleting() []netip.Addr

func (Set) Idles

func (s Set) Idles() []*IP

func (Set) InUse

func (s Set) InUse() []*IP

func (Set) PeekAvailable

func (s Set) PeekAvailable(podID string) *IP

func (Set) PutDeleting

func (s Set) PutDeleting(ip ...netip.Addr)

func (Set) PutValid

func (s Set) PutValid(ip ...netip.Addr)

func (Set) Release

func (s Set) Release(podID string, ip netip.Addr)

type Status

type Status struct {
	NetworkInterfaceID   string
	MAC                  string
	Type                 string
	AllocInhibitExpireAt string

	Usage  [][]string
	Status string
}

type Trace

type Trace struct {
	Condition ConditionType
	Reason    string
}

type Trunk

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

func NewTrunk

func NewTrunk(client client.Client, local *Local) *Trunk

func (*Trunk) Allocate

func (r *Trunk) Allocate(ctx context.Context, cni *daemon.CNI, request ResourceRequest) (chan *AllocResp, []Trace)

func (*Trunk) Dispose

func (r *Trunk) Dispose(n int) int

func (*Trunk) Priority

func (r *Trunk) Priority() int

func (*Trunk) Release

func (r *Trunk) Release(ctx context.Context, cni *daemon.CNI, request NetworkResource) (bool, error)

func (*Trunk) Run

func (r *Trunk) Run(ctx context.Context, podResources []daemon.PodResources, wg *sync.WaitGroup) error

func (*Trunk) Status

func (r *Trunk) Status() Status

func (*Trunk) Usage

func (r *Trunk) Usage() (int, int, error)

type Usage

type Usage interface {
	Usage() (int, int, error)
}

Jump to

Keyboard shortcuts

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