tainteviction

package
v1.33.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: Apache-2.0 Imports: 28 Imported by: 1

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 NamespacedObject added in v1.33.0

type NamespacedObject struct {
	types.NamespacedName
	UID types.UID
}

NamespacedObject comprises a resource name with a mandatory namespace and optional UID. It gets rendered as "<namespace>/<name>[:<uid>]" (text output) or as an object (JSON output).

func (NamespacedObject) MarshalLog added in v1.33.0

func (n NamespacedObject) MarshalLog() interface{}

MarshalLog emits a struct containing required key/value pair

func (NamespacedObject) String added in v1.33.0

func (n NamespacedObject) String() string

String returns the general purpose string representation

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`. If replace is false, an existing work item will not get replaced, otherwise it gets canceled and the new one is added instead.

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. The key must be the same as the one returned by WorkArgs.KeyFromWorkArgs, i.e. the result of NamespacedName.String.

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.

func (*TimedWorkerQueue) UpdateWork added in v1.33.0

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

UpdateWork adds or replaces a work item such that it will be executed not earlier than `fireAt`. This is a cheap no-op when the old and new fireAt are the same.

type WorkArgs

type WorkArgs struct {
	// Object is the work item. The UID is only set if it was set when adding the work item.
	Object NamespacedObject
}

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` without a UID.

func (*WorkArgs) KeyFromWorkArgs

func (w *WorkArgs) KeyFromWorkArgs() string

KeyFromWorkArgs creates a key for the given `WorkArgs`.

The key is the same as the NamespacedName of the object in the work item, i.e. the UID is ignored. There cannot be two different work items with the same NamespacedName and different UIDs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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