cleanup

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

common filters for describing network interfaces

Functions

This section is empty.

Types

type ClusterENICleaner

type ClusterENICleaner struct {
	ClusterName string

	*ENICleaner
	// contains filtered or unexported fields
}

ClusterENICleaner periodically deletes leaked network interfaces(provisioned by the controller or VPC-CNI) in the cluster

func (*ClusterENICleaner) GetENITagFilters

func (e *ClusterENICleaner) GetENITagFilters() []*ec2.Filter

func (*ClusterENICleaner) SetupWithManager

func (e *ClusterENICleaner) SetupWithManager(ctx context.Context, mgr ctrl.Manager, healthzHandler *rcHealthz.HealthzHandler) error

func (*ClusterENICleaner) ShouldDeleteENI

func (e *ClusterENICleaner) ShouldDeleteENI(eniID *string) bool

ShouldDeleteENI returns true if the ENI should be deleted.

func (*ClusterENICleaner) Start

func (e *ClusterENICleaner) Start(ctx context.Context) error

StartENICleaner starts the ENI Cleaner routine that cleans up dangling ENIs created by the controller

func (*ClusterENICleaner) UpdateAvailableENIsIfNeeded

func (e *ClusterENICleaner) UpdateAvailableENIsIfNeeded(eniMap *map[string]struct{})

Example 1st cycle, Describe Available NetworkInterface Result - Interface 1, Interface 2, Interface 3 2nd cycle, Describe Available NetworkInterface Result - Interface 2, Interface 3 In the second cycle we can conclude that Interface 2 and 3 are leaked because they have been sitting for the time interval between cycle 1 and 2 and hence can be safely deleted. And we can also conclude that Interface 1 was created but not attached at the the time when 1st cycle ran and hence it should not be deleted.

func (*ClusterENICleaner) UpdateCleanupMetrics

func (e *ClusterENICleaner) UpdateCleanupMetrics(vpcrcAvailableCount int, vpccniAvailableCount int, leakedENICount int)

Update cluster cleanup metrics for the current cleanup cycle

type ENICleaner

type ENICleaner struct {
	EC2Wrapper api.EC2Wrapper
	Manager    NetworkInterfaceManager
	VPCID      string
	Log        logr.Logger
}

func (*ENICleaner) DeleteLeakedResources

func (e *ENICleaner) DeleteLeakedResources() error

DeleteLeakedResources describes all the network interfaces in available status that are created by the controller or VPC-CNI This is called by periodically by ClusterENICleaner which deletes available ENIs cluster-wide, and by the NodeTermination cleaner on node termination The available ENIs are deleted if ShouldDeleteENI is true, defined in the respective cleaners The function also updates metrics for the periodic cleanup routine and the node termination cleanup

type NetworkInterfaceManager

type NetworkInterfaceManager interface {
	GetENITagFilters() []*ec2.Filter
	ShouldDeleteENI(eniID *string) bool
	UpdateAvailableENIsIfNeeded(eniMap *map[string]struct{})
	UpdateCleanupMetrics(vpcrcAvailableCount int, vpccniAvailableCount int, leakedENICount int)
}

NetworkInterfaceManager interface allows to define the ENI filters and checks if ENI should be deleted for different callers like in the periodic cleanup routine or during node termination

type NodeTerminationCleaner

type NodeTerminationCleaner struct {
	NodeName string
	*ENICleaner
}

NodeTerminationCleanerto handle resource cleanup at node termination

func (*NodeTerminationCleaner) GetENITagFilters

func (n *NodeTerminationCleaner) GetENITagFilters() []*ec2.Filter

func (*NodeTerminationCleaner) ShouldDeleteENI

func (n *NodeTerminationCleaner) ShouldDeleteENI(eniID *string) bool

Return true. As the node is terminating all available ENIs need to be deleted

func (*NodeTerminationCleaner) UpdateAvailableENIsIfNeeded

func (n *NodeTerminationCleaner) UpdateAvailableENIsIfNeeded(eniMap *map[string]struct{})

func (*NodeTerminationCleaner) UpdateCleanupMetrics

func (n *NodeTerminationCleaner) UpdateCleanupMetrics(vpcrcAvailableCount int, vpccniAvailableCount int, leakedENICount int)

Updating node termination metrics does not make much sense as it will be updated on each node deletion and does not give us much info

type ResourceCleaner

type ResourceCleaner interface {
	DeleteLeakedResources() error
}

ResourceCleaner interface should be implemented by components that need to delete leaked AWS resources

Jump to

Keyboard shortcuts

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