controller

package
v1.3.8 Latest Latest
Warning

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

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

Documentation

Overview

Package controller implements the Kubernetes controller for managing AWS Elastic Network Interfaces (ENIs) for nodes.

The NodeENI controller watches NodeENI custom resources and automatically creates, attaches, and manages ENIs for nodes that match the specified selectors. It supports multiple subnets and security groups, and handles the lifecycle of ENIs including creation, attachment, detachment, and deletion.

Index

Constants

View Source
const (
	CleanupStartTimeAnnotation = "aws-multi-eni-controller/cleanup-start-time"
)

Constants for cleanup tracking annotations

View Source
const (
	// NodeENIFinalizer is the finalizer added to NodeENI resources
	NodeENIFinalizer = "nodeeni.networking.k8s.aws/finalizer"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CoordinatedOperation added in v1.3.3

type CoordinatedOperation struct {
	ID          string
	Type        string
	ResourceIDs []string
	Priority    int
	DependsOn   []string
	Timeout     time.Duration
	Execute     func(ctx context.Context) error
}

CoordinatedOperation represents an operation that requires coordination

type CoordinationManager added in v1.3.3

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

CoordinationManager manages resource locks and operation dependencies

func NewCoordinationManager added in v1.3.3

func NewCoordinationManager(logger logr.Logger) *CoordinationManager

NewCoordinationManager creates a new coordination manager

func (*CoordinationManager) AcquireLock added in v1.3.3

func (cm *CoordinationManager) AcquireLock(ctx context.Context, resourceID, resourceType, operationID string, timeout time.Duration) (*ResourceLock, error)

AcquireLock attempts to acquire a lock on a resource

func (*CoordinationManager) CheckDependencies added in v1.3.3

func (cm *CoordinationManager) CheckDependencies(operationID string) (bool, []string)

CheckDependencies checks if an operation's dependencies are satisfied

func (*CoordinationManager) CleanupStaleLocks added in v1.3.3

func (cm *CoordinationManager) CleanupStaleLocks()

CleanupStaleLocks removes locks that have expired or been cancelled

func (*CoordinationManager) CompleteDependency added in v1.3.3

func (cm *CoordinationManager) CompleteDependency(operationID string)

CompleteDependency marks an operation as complete

func (*CoordinationManager) ExecuteCoordinated added in v1.3.3

func (cm *CoordinationManager) ExecuteCoordinated(ctx context.Context, op *CoordinatedOperation) error

ExecuteCoordinated executes an operation with proper coordination

func (*CoordinationManager) GetDependencyStatus added in v1.3.3

func (cm *CoordinationManager) GetDependencyStatus() map[string]OperationDependency

GetDependencyStatus returns the current status of all dependencies

func (*CoordinationManager) GetLockStatus added in v1.3.3

func (cm *CoordinationManager) GetLockStatus() map[string]ResourceLock

GetLockStatus returns the current status of all locks

func (*CoordinationManager) GetResourceConflicts added in v1.3.3

func (cm *CoordinationManager) GetResourceConflicts(resourceIDs []string) []string

GetResourceConflicts checks for potential resource conflicts

func (*CoordinationManager) RegisterDependency added in v1.3.3

func (cm *CoordinationManager) RegisterDependency(operationID string, dependsOn []string, resourceIDs []string, priority int)

RegisterDependency registers an operation dependency

func (*CoordinationManager) ReleaseLock added in v1.3.3

func (cm *CoordinationManager) ReleaseLock(resourceID, operationID string) error

ReleaseLock releases a lock on a resource

type Dependency added in v1.3.3

type Dependency struct {
	ID            string
	Type          DependencyType
	ResourceID    string
	DependsOn     []string
	RequiredState ResourceState
	Priority      int
	CreatedAt     time.Time
	Metadata      map[string]interface{}
}

Dependency represents a dependency between resources

type DependencyGraph added in v1.3.3

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

DependencyGraph represents a graph of dependencies

func NewDependencyGraph added in v1.3.3

func NewDependencyGraph(logger logr.Logger) *DependencyGraph

NewDependencyGraph creates a new dependency graph

func (*DependencyGraph) AddDependency added in v1.3.3

func (dg *DependencyGraph) AddDependency(dep *Dependency) error

AddDependency adds a dependency to the graph

func (*DependencyGraph) GetBlockedDependencies added in v1.3.3

func (dg *DependencyGraph) GetBlockedDependencies() []*Dependency

GetBlockedDependencies returns dependencies that are blocked

func (*DependencyGraph) GetDependencyConflicts added in v1.3.3

func (dg *DependencyGraph) GetDependencyConflicts() []string

GetDependencyConflicts returns conflicts between dependencies

func (*DependencyGraph) GetReadyDependencies added in v1.3.3

func (dg *DependencyGraph) GetReadyDependencies() []*Dependency

GetReadyDependencies returns dependencies that are ready to be processed

func (*DependencyGraph) GetResourceState added in v1.3.3

func (dg *DependencyGraph) GetResourceState(resourceID string) ResourceState

GetResourceState gets the current state of a resource

func (*DependencyGraph) RemoveDependency added in v1.3.3

func (dg *DependencyGraph) RemoveDependency(id string)

RemoveDependency removes a dependency from the graph

func (*DependencyGraph) ResolveDependencyOrder added in v1.3.3

func (dg *DependencyGraph) ResolveDependencyOrder() ([]*Dependency, error)

ResolveDependencyOrder returns dependencies in the order they should be processed

func (*DependencyGraph) UpdateResourceState added in v1.3.3

func (dg *DependencyGraph) UpdateResourceState(resourceID string, state ResourceState)

UpdateResourceState updates the state of a resource

type DependencyManager added in v1.3.3

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

DependencyManager manages resource dependencies for ENI operations

func NewDependencyManager added in v1.3.3

func NewDependencyManager(logger logr.Logger) *DependencyManager

NewDependencyManager creates a new dependency manager

func (*DependencyManager) CompleteDependency added in v1.3.3

func (dm *DependencyManager) CompleteDependency(dependencyID string)

CompleteDependency marks a dependency as completed

func (*DependencyManager) CreateENIAttachmentDependencies added in v1.3.3

func (dm *DependencyManager) CreateENIAttachmentDependencies(ctx context.Context, nodeENI *networkingv1alpha1.NodeENI, attachment networkingv1alpha1.ENIAttachment) error

CreateENIAttachmentDependencies creates dependencies for ENI attachment

func (*DependencyManager) CreateENIDetachmentDependencies added in v1.3.3

func (dm *DependencyManager) CreateENIDetachmentDependencies(ctx context.Context, nodeENI *networkingv1alpha1.NodeENI, attachment networkingv1alpha1.ENIAttachment) error

CreateENIDetachmentDependencies creates dependencies for ENI detachment

func (*DependencyManager) GetDependencyStatus added in v1.3.3

func (dm *DependencyManager) GetDependencyStatus() map[string]interface{}

GetDependencyStatus returns the current status of all dependencies

func (*DependencyManager) GetReadyOperations added in v1.3.3

func (dm *DependencyManager) GetReadyOperations() []*Dependency

GetReadyOperations returns operations that are ready to be executed

func (*DependencyManager) UpdateResourceState added in v1.3.3

func (dm *DependencyManager) UpdateResourceState(resourceID string, state ResourceState)

UpdateResourceState updates the state of a resource

type DependencyType added in v1.3.3

type DependencyType int

DependencyType represents different types of dependencies

const (
	// DependencyTypeInstance - dependency on instance state
	DependencyTypeInstance DependencyType = iota
	// DependencyTypeSubnet - dependency on subnet availability
	DependencyTypeSubnet
	// DependencyTypeENI - dependency on ENI state
	DependencyTypeENI
	// DependencyTypeNode - dependency on node state
	DependencyTypeNode
	// DependencyTypeSecurityGroup - dependency on security group
	DependencyTypeSecurityGroup
)

type InterfaceState added in v1.3.3

type InterfaceState struct {
	PCIAddress    string
	CurrentDriver string
	IfaceName     string
	IsBoundToDPDK bool
}

InterfaceState represents the current state of a network interface

type NodeENIReconciler

type NodeENIReconciler struct {
	client.Client
	Log            logr.Logger
	Scheme         *runtime.Scheme
	Recorder       record.EventRecorder
	AWS            awsutil.EC2Interface
	Config         *config.ControllerConfig
	CircuitBreaker *retry.CircuitBreaker
	Coordinator    *CoordinationManager
	Metrics        *observability.Metrics
	StructuredLog  *observability.StructuredLogger
}

NodeENIReconciler reconciles a NodeENI object

func NewNodeENIReconciler

func NewNodeENIReconciler(mgr manager.Manager) (*NodeENIReconciler, error)

NewNodeENIReconciler creates a new NodeENI controller

func (*NodeENIReconciler) Reconcile

func (r *NodeENIReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile handles NodeENI resources +kubebuilder:rbac:groups=networking.k8s.aws,resources=nodeenis,verbs=get;list;watch;create;update;patch;delete +kubebuilder:rbac:groups=networking.k8s.aws,resources=nodeenis/status,verbs=get;update;patch +kubebuilder:rbac:groups=core,resources=nodes,verbs=get;list;watch +kubebuilder:rbac:groups=core,resources=events,verbs=create;patch

func (*NodeENIReconciler) SetupWithManager

func (r *NodeENIReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager

func (*NodeENIReconciler) ShouldUseNodeLevelCoordinationTest added in v1.3.8

func (r *NodeENIReconciler) ShouldUseNodeLevelCoordinationTest(nodeENI *networkingv1alpha1.NodeENI, attachment networkingv1alpha1.ENIAttachment) bool

ShouldUseNodeLevelCoordinationTest exposes shouldUseNodeLevelCoordination for testing purposes

type OperationDependency added in v1.3.3

type OperationDependency struct {
	OperationID string
	DependsOn   []string
	ResourceIDs []string
	Priority    int
}

OperationDependency represents a dependency between operations

type ResourceLock added in v1.3.3

type ResourceLock struct {
	ResourceID   string
	ResourceType string
	LockedAt     time.Time
	LockedBy     string
	Context      context.Context
	Cancel       context.CancelFunc
}

ResourceLock represents a lock on a specific resource

type ResourceState added in v1.3.3

type ResourceState int

ResourceState represents the state of a resource

const (
	// ResourceStateUnknown - state is unknown
	ResourceStateUnknown ResourceState = iota
	// ResourceStateAvailable - resource is available
	ResourceStateAvailable
	// ResourceStateInUse - resource is in use
	ResourceStateInUse
	// ResourceStateUnavailable - resource is unavailable
	ResourceStateUnavailable
	// ResourceStateDeleting - resource is being deleted
	ResourceStateDeleting
)

Jump to

Keyboard shortcuts

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