tainteviction

package
v1.30.5 Latest Latest
Warning

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

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

Documentation

Overview

Package tainteviction contains the logic implementing taint-based eviction for Pods running on Nodes with NoExecute taints.

Index

Constants

View Source
const (

	// NodeUpdateChannelSize defines the size of channel for node update events.
	NodeUpdateChannelSize = 10
	// UpdateWorkerSize defines the size of workers for node update or/and pod update.
	UpdateWorkerSize = 8
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

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

Controller listens to Taint/Toleration changes and is responsible for removing Pods from Nodes tainted with NoExecute Taints.

func New

func New(ctx context.Context, c clientset.Interface, podInformer corev1informers.PodInformer, nodeInformer corev1informers.NodeInformer, controllerName string) (*Controller, error)

New creates a new Controller that will use passed clientset to communicate with the API server.

func (*Controller) NodeUpdated

func (tc *Controller) NodeUpdated(oldNode *v1.Node, newNode *v1.Node)

NodeUpdated is used to notify NoExecuteTaintManager about Node changes.

func (*Controller) PodUpdated

func (tc *Controller) PodUpdated(oldPod *v1.Pod, newPod *v1.Pod)

PodUpdated is used to notify NoExecuteTaintManager about Pod changes.

func (*Controller) Run

func (tc *Controller) Run(ctx context.Context)

Run starts the controller which will run in loop until `stopCh` is closed.

type GetPodsByNodeNameFunc

type GetPodsByNodeNameFunc func(nodeName string) ([]*v1.Pod, error)

GetPodsByNodeNameFunc returns the list of pods assigned to the specified node.

type TimedWorker

type TimedWorker struct {
	WorkItem  *WorkArgs
	CreatedAt time.Time
	FireAt    time.Time
	Timer     clock.Timer
}

TimedWorker is a responsible for executing a function no earlier than at FireAt time.

func (*TimedWorker) Cancel

func (w *TimedWorker) Cancel()

Cancel cancels the execution of function by the `TimedWorker`

type TimedWorkerQueue

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

TimedWorkerQueue keeps a set of TimedWorkers that are still wait for execution.

func CreateWorkerQueue

func CreateWorkerQueue(f func(ctx context.Context, fireAt time.Time, args *WorkArgs) error) *TimedWorkerQueue

CreateWorkerQueue creates a new TimedWorkerQueue for workers that will execute given function `f`.

func (*TimedWorkerQueue) AddWork

func (q *TimedWorkerQueue) AddWork(ctx context.Context, args *WorkArgs, createdAt time.Time, fireAt time.Time)

AddWork adds a work to the WorkerQueue which will be executed not earlier than `fireAt`.

func (*TimedWorkerQueue) CancelWork

func (q *TimedWorkerQueue) CancelWork(logger klog.Logger, key string) bool

CancelWork removes scheduled function execution from the queue. Returns true if work was cancelled.

func (*TimedWorkerQueue) GetWorkerUnsafe

func (q *TimedWorkerQueue) GetWorkerUnsafe(key string) *TimedWorker

GetWorkerUnsafe returns a TimedWorker corresponding to the given key. Unsafe method - workers have attached goroutines which can fire after this function is called.

type WorkArgs

type WorkArgs struct {
	NamespacedName types.NamespacedName
}

WorkArgs keeps arguments that will be passed to the function executed by the worker.

func NewWorkArgs

func NewWorkArgs(name, namespace string) *WorkArgs

NewWorkArgs is a helper function to create new `WorkArgs`

func (*WorkArgs) KeyFromWorkArgs

func (w *WorkArgs) KeyFromWorkArgs() string

KeyFromWorkArgs creates a key for the given `WorkArgs`

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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