pool

package
v1.8.3 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxENI = errors.New("max eni executed")

Functions

func AllocTypeWithCtx

func AllocTypeWithCtx(ctx context.Context, allocType AllocPolicy) context.Context

Types

type AllocManager

type AllocManager struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAllocManager

func NewAllocManager(max int, enableTrunk bool) *AllocManager

func (*AllocManager) Add

func (a *AllocManager) Add(alloc *Allocation)

func (*AllocManager) Alloc

func (a *AllocManager) Alloc(vSwitchID string) *client.NetworkInterface

Alloc try alloc eni by vSwitchID

func (*AllocManager) Dispose

func (a *AllocManager) Dispose(eniID string)

func (*AllocManager) Load

func (a *AllocManager) Load(eniID string) *Allocation

func (*AllocManager) Range

func (a *AllocManager) Range(f func(key string, value *Allocation) bool)

func (*AllocManager) Release

func (a *AllocManager) Release(eniID string)

Release set status to StatusIdle

func (*AllocManager) ReleaseIdle

func (a *AllocManager) ReleaseIdle() *client.NetworkInterface

ReleaseIdle pick one idle and set status to StatusDeleting

func (*AllocManager) ReleaseQuota

func (a *AllocManager) ReleaseQuota()

func (*AllocManager) RequireQuota

func (a *AllocManager) RequireQuota() bool

type AllocPolicy

type AllocPolicy int
const (
	AllocPolicyDirect AllocPolicy = iota
	AllocPolicyPreferPool
)

func AllocPolicyCtx

func AllocPolicyCtx(ctx context.Context) AllocPolicy

type Allocation

type Allocation struct {
	sync.RWMutex
	NetworkInterface *client.NetworkInterface // find a way to update the fields
	Status           Status
	AllocType        AllocPolicy
}

Allocation store eni alloc status

func (*Allocation) GetNetworkInterface

func (a *Allocation) GetNetworkInterface() *client.NetworkInterface

func (*Allocation) GetStatus

func (a *Allocation) GetStatus() Status

func (*Allocation) SetStatus

func (a *Allocation) SetStatus(status Status)

type Config

type Config struct {
	IPv4Enable bool
	IPv6Enable bool

	NodeName string
	// instance metadata
	InstanceID string
	ZoneID     string
	TrunkENIID string

	// eni
	VSwitchIDs       []string
	SecurityGroupIDs []string
	ENITags          map[string]string

	// pool config
	MaxENI  int // max eni manager can allocate
	MaxIdle int
	MinIdle int

	SyncPeriod time.Duration
}

Config for eni manager

type Manager

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

func NewManager

func NewManager(cfg *Config, previous map[string]*Allocation, vSwitchPool *vswitch.SwitchPool, aliyun register.Interface) *Manager

func (*Manager) AssignIpv6Addresses

func (m *Manager) AssignIpv6Addresses(ctx context.Context, eniID string, count int, idempotentKey string) ([]netip.Addr, error)

func (*Manager) AssignPrivateIPAddress

func (m *Manager) AssignPrivateIPAddress(ctx context.Context, eniID string, count int, idempotent string) ([]netip.Addr, error)

func (*Manager) AttachNetworkInterface

func (m *Manager) AttachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error

func (*Manager) CreateNetworkInterface

func (m *Manager) CreateNetworkInterface(ctx context.Context, trunk, erdma bool, vSwitchID string, securityGroups []string, resourceGroupID string, ipCount, ipv6Count int, eniTags map[string]string) (*aliyunClient.NetworkInterface, error)

func (*Manager) DeleteNetworkInterface

func (m *Manager) DeleteNetworkInterface(ctx context.Context, eniID string) (err error)

func (*Manager) DescribeInstanceTypes

func (m *Manager) DescribeInstanceTypes(ctx context.Context, types []string) ([]ecs.InstanceType, error)

func (*Manager) DescribeNetworkInterface

func (m *Manager) DescribeNetworkInterface(ctx context.Context, vpcID string, eniID []string, instanceID string, instanceType string, status string, tags map[string]string) ([]*aliyunClient.NetworkInterface, error)

func (*Manager) DescribeVSwitchByID

func (m *Manager) DescribeVSwitchByID(ctx context.Context, vSwitchID string) (*vpc.VSwitch, error)

func (*Manager) DetachNetworkInterface

func (m *Manager) DetachNetworkInterface(ctx context.Context, eniID, instanceID, trunkENIID string) error

func (*Manager) ModifyNetworkInterfaceAttribute

func (m *Manager) ModifyNetworkInterfaceAttribute(ctx context.Context, eniID string, securityGroupIDs []string) error

func (*Manager) Run

func (m *Manager) Run()

func (*Manager) Stop

func (m *Manager) Stop()

func (*Manager) UnAssignIpv6Addresses

func (m *Manager) UnAssignIpv6Addresses(ctx context.Context, eniID string, ips []netip.Addr) error

func (*Manager) UnAssignPrivateIPAddresses

func (m *Manager) UnAssignPrivateIPAddresses(ctx context.Context, eniID string, ips []netip.Addr) error

func (*Manager) WaitForNetworkInterface

func (m *Manager) WaitForNetworkInterface(ctx context.Context, eniID string, status string, bo wait.Backoff, ignoreNotExist bool) (*aliyunClient.NetworkInterface, error)

type Status

type Status string
const (
	StatusIdle      Status = "idle"
	StatusInUse     Status = "inUse"
	StatusDeleting  Status = "deleting"
	StatusUnManaged Status = "unManaged"
)

Jump to

Keyboard shortcuts

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