eni

package
v1.8.12 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2024 License: Apache-2.0 Imports: 29 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

This section is empty.

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 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 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

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
}

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, 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
	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

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[any]*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

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)
}

type Veth

type Veth struct{}

func (*Veth) Allocate

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

func (*Veth) Dispose

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

func (*Veth) Priority

func (r *Veth) Priority() int

func (*Veth) Release

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

func (*Veth) Run

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

type VethRequest

type VethRequest struct{}

func (*VethRequest) ResourceType

func (l *VethRequest) ResourceType() ResourceType

type VethResource

type VethResource struct {
	Name string
}

func (VethResource) ResourceType

func (v VethResource) ResourceType() ResourceType

func (VethResource) ToRPC

func (v VethResource) ToRPC() []*rpc.NetConf

func (VethResource) ToStore

func (v VethResource) ToStore() []daemon.ResourceItem

Jump to

Keyboard shortcuts

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