Documentation
¶
Index ¶
- Constants
- Variables
- func IPUsage(eniIP map[string]*networkv1beta1.IP) (int, int)
- func IdlesWithAvailable(eniIP map[string]*networkv1beta1.IP) (count int)
- func Notify(ctx context.Context, name string)
- type Condition
- type ENIOperation
- type ENITaskQueue
- func (q *ENITaskQueue) CleanupStaleTasks(nodeName string, validENIIDs map[string]struct{}, staleThreshold time.Duration) []string
- func (q *ENITaskQueue) DeleteTasks(eniIDs []string)
- func (q *ENITaskQueue) GetAttachingCount(nodeName string) int
- func (q *ENITaskQueue) GetPendingENIs(nodeName string) []string
- func (q *ENITaskQueue) GetQueueStats() map[ENITaskStatus]int
- func (q *ENITaskQueue) GetTaskStatus(eniID string) (*ENITaskRecord, bool)
- func (q *ENITaskQueue) HasPendingTasks(nodeName string) bool
- func (q *ENITaskQueue) PeekCompletedTasks(nodeName string) []*ENITaskRecord
- func (q *ENITaskQueue) RemoveTask(eniID string)
- func (q *ENITaskQueue) RemoveTasks(nodeName string)
- func (q *ENITaskQueue) SubmitAttach(ctx context.Context, eniID, instanceID, trunkENIID, nodeName string, ...)
- type ENITaskRecord
- type ENITaskStatus
- type EniIP
- type NodeStatus
- type PodRequest
- type ReconcileNode
Constants ¶
const ( ConditionInsufficientIP = "InsufficientIP" ConditionOperationErr = "OperationErr" )
const ( ControllerName = "multi-ip-node" // Event reasons EventAllocIPFailed = "AllocIPFailed" EventSyncOpenAPISuccess = "SyncOpenAPISuccess" EventSyncOpenAPIFailed = "SyncOpenAPIFailed" )
Variables ¶
var ( // ResourcePoolTotal terway total source amount in the pool ResourcePoolTotal = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "gc_count_total", Help: "controlplane gc total", }, []string{"node"}, ) SyncOpenAPITotal = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "sync_openapi_count_total", Help: "controlplane sync data with openapi total", }, []string{"node"}, ) // ReconcileLatency records the latency of different reconcile methods ReconcileLatency = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "controlplane_node_reconcile_latency_ms", Help: "Latency of node controller reconcile methods in milliseconds", Buckets: []float64{10, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 30000, 60000}, }, []string{"method", "node"}, ) // ENITaskQueueSize shows the current size of ENI task queue by status ENITaskQueueSize = prometheus.NewGaugeVec( prometheus.GaugeOpts{ Name: "terway_eni_task_queue_size", Help: "Current size of ENI task queue", }, []string{"status"}, ) // ENIAttachDuration records the duration of ENI attach operations ENIAttachDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Name: "terway_eni_attach_duration_seconds", Help: "Duration of ENI attach operations", Buckets: []float64{1, 3, 5, 10, 20, 30, 60, 120, 180}, }, []string{"result", "eni_type"}, ) )
var EniOptions = map[eniTypeKey]*aliyunClient.CreateNetworkInterfaceOptions{ // contains filtered or unexported fields }
var EventCh = make(chan event.GenericEvent, 1000)
Functions ¶
func IdlesWithAvailable ¶
func IdlesWithAvailable(eniIP map[string]*networkv1beta1.IP) (count int)
Types ¶
type ENIOperation ¶ added in v1.16.5
type ENIOperation string
ENIOperation represents an ENI operation type
const ( OpAttach ENIOperation = "Attach" OpDetach ENIOperation = "Detach" OpDelete ENIOperation = "Delete" )
type ENITaskQueue ¶ added in v1.16.5
type ENITaskQueue struct {
// contains filtered or unexported fields
}
ENITaskQueue manages async ENI operations
func NewENITaskQueue ¶ added in v1.16.5
func NewENITaskQueue(ctx context.Context, executor *ops.Executor, notifyCh chan string) *ENITaskQueue
NewENITaskQueue creates a new task queue
func (*ENITaskQueue) CleanupStaleTasks ¶ added in v1.16.5
func (q *ENITaskQueue) CleanupStaleTasks(nodeName string, validENIIDs map[string]struct{}, staleThreshold time.Duration) []string
CleanupStaleTasks removes tasks that are orphaned or stale - Tasks for ENIs not in validENIIDs are considered orphaned - Completed tasks older than staleThreshold are considered stale
func (*ENITaskQueue) DeleteTasks ¶ added in v1.16.5
func (q *ENITaskQueue) DeleteTasks(eniIDs []string)
DeleteTasks removes specific tasks from the queue
func (*ENITaskQueue) GetAttachingCount ¶ added in v1.16.5
func (q *ENITaskQueue) GetAttachingCount(nodeName string) int
GetAttachingCount returns the number of ENIs currently being attached for a node. This includes both in-queue tasks (Pending/Running) to help enforce concurrent attach limits.
func (*ENITaskQueue) GetPendingENIs ¶ added in v1.16.5
func (q *ENITaskQueue) GetPendingENIs(nodeName string) []string
GetPendingENIs returns ENI IDs that are still pending/running for a node
func (*ENITaskQueue) GetQueueStats ¶ added in v1.16.5
func (q *ENITaskQueue) GetQueueStats() map[ENITaskStatus]int
GetQueueStats returns queue statistics for metrics
func (*ENITaskQueue) GetTaskStatus ¶ added in v1.16.5
func (q *ENITaskQueue) GetTaskStatus(eniID string) (*ENITaskRecord, bool)
GetTaskStatus returns the current status of a task
func (*ENITaskQueue) HasPendingTasks ¶ added in v1.16.5
func (q *ENITaskQueue) HasPendingTasks(nodeName string) bool
HasPendingTasks checks if there are any pending tasks for a node
func (*ENITaskQueue) PeekCompletedTasks ¶ added in v1.16.5
func (q *ENITaskQueue) PeekCompletedTasks(nodeName string) []*ENITaskRecord
PeekCompletedTasks returns all completed/failed tasks for a node without removing them
func (*ENITaskQueue) RemoveTask ¶ added in v1.16.5
func (q *ENITaskQueue) RemoveTask(eniID string)
RemoveTask removes a task from the queue
func (*ENITaskQueue) RemoveTasks ¶ added in v1.16.5
func (q *ENITaskQueue) RemoveTasks(nodeName string)
RemoveTasks removes all tasks for a specific node
func (*ENITaskQueue) SubmitAttach ¶ added in v1.16.5
func (q *ENITaskQueue) SubmitAttach(ctx context.Context, eniID, instanceID, trunkENIID, nodeName string, requestedIPv4, requestedIPv6 int)
SubmitAttach submits an async attach task with requested IP counts This method never fails - it only adds a task to in-memory queue
type ENITaskRecord ¶ added in v1.16.5
type ENITaskRecord struct {
ENIID string
Operation ENIOperation
InstanceID string
TrunkENIID string
NodeName string
// BackendAPI stores the backend type (ECS or EFLO) for this task.
// This is needed because the task runs asynchronously and needs to use
// the correct backend API for attach/query operations.
BackendAPI aliyunClient.BackendAPI
Status ENITaskStatus
CreatedAt time.Time
CompletedAt *time.Time
// Record the number of IPs requested when creating ENI, used for quota calculation
RequestedIPv4Count int
RequestedIPv6Count int
// Result after completion
ENIInfo *aliyunClient.NetworkInterface
Error error
}
ENITaskRecord stores the state of an ENI operation task
type ENITaskStatus ¶ added in v1.16.5
type ENITaskStatus string
ENITaskStatus represents the status of an ENI task
const ( TaskStatusPending ENITaskStatus = "Pending" TaskStatusRunning ENITaskStatus = "Running" TaskStatusCompleted ENITaskStatus = "Completed" TaskStatusFailed ENITaskStatus = "Failed" TaskStatusTimeout ENITaskStatus = "Timeout" )
type EniIP ¶
type EniIP struct {
NetworkInterface *networkv1beta1.Nic
IP *networkv1beta1.IP
}
type NodeStatus ¶
type NodeStatus struct {
NeedSyncOpenAPI *atomic.Bool
StatusChanged *atomic.Bool
LastGCTime time.Time
LastReconcileTime time.Time
ProcessedTaskIDs []string
Mutex sync.Mutex
}
func MetaCtx ¶
func MetaCtx(ctx context.Context) *NodeStatus