pool

package
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0 Imports: 19 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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) ([]net.IP, error)

func (*Manager) AssignPrivateIPAddress

func (m *Manager) AssignPrivateIPAddress(ctx context.Context, eniID string, count int, idempotentKey string) ([]net.IP, 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 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 []net.IP) error

func (*Manager) UnAssignPrivateIPAddresses

func (m *Manager) UnAssignPrivateIPAddresses(ctx context.Context, eniID string, ips []net.IP) 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