drain

package
v0.1.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDrainRequestExists = errors.New("drain request exists")

ErrDrainRequestExists error means drain request exists

Functions

func DrainRequestUIDFromNodeMaintenance

func DrainRequestUIDFromNodeMaintenance(nm *maintenancev1.NodeMaintenance) string

DrainRequestUIDFromNodeMaintenance returns DrainRequest UID of given NodeMaintenance object.

Types

type DrainRequest

type DrainRequest interface {
	// UID returns DrainRequest UID.
	UID() string
	// StartDrain starts drain. drain will be performed to completion or until canceled.
	// a DrainRequest can StartDrain only once. this is a non-blocking operations.
	StartDrain()
	// CancelDrain cancels a started DrainRequest. Blocks until DrainRequest in canceled.
	CancelDrain()
	// Status returns current DrainStatus of a DrainRequest.
	Status() (DrainStatus, error)
	// State returns current DrainState of a DrainRequest.
	State() DrainState
	// Spec returns the request's DrainRequestSpec.
	Spec() DrainRequestSpec
	// LastError returns the last error that occurred during Drain operation of DrainRequest
	// it returns error if drain request completed with error. returns nil otherwise.
	LastError() error
}

DrainRequest is an interface to perform drain for a node

func NewDrainRequest

func NewDrainRequest(ctx context.Context, log logr.Logger, k8sInterface kubernetes.Interface, nm *maintenancev1.NodeMaintenance, disableEviction bool) DrainRequest

NewDrainRequest creates a new DrainRequest.

type DrainRequestSpec

type DrainRequestSpec struct {
	// NodeName is the name of the node for drain
	NodeName string
	// Spec is the DrainSpec as defined in NodeMaintenance CRD
	Spec maintenancev1.DrainSpec
}

DrainRequestSpec is the DrainRequest spec

type DrainState

type DrainState string

DrainState is the state of the drain request

const (
	// DrainStateNotStarted means drain request has not been started
	DrainStateNotStarted DrainState = "NotStarted"
	// DrainStateInProgress means drain request is in progress
	DrainStateInProgress DrainState = "InProgress"
	// DrainStateCanceled means drain request got canceled
	DrainStateCanceled DrainState = "Caneceled"
	// DrainStateSuccess means drain request completed successfully
	DrainStateSuccess DrainState = "Success"
	// DrainStateSuccess means drain request completed with error
	DrainStateError DrainState = "Error"

	// DrainDeleted is drain Deleted string
	DrainDeleted = "Deleted"
	// DrainEvicted is drain Evicted string
	DrainEvicted = "Evicted"
)

type DrainStatus

type DrainStatus struct {
	// State is the state of the DrainRequest
	State DrainState
	// PodsToDelete are the list of namespace/name pods that are pending deletion/eviction
	PodsToDelete []string
}

DrainStatus is the status of drain

type Manager

type Manager interface {
	// NewDrainRequest creates a new DrainRequest for NodeMaintenance
	NewDrainRequest(*maintenancev1.NodeMaintenance) DrainRequest
	// AddRequest adds req to Manager. returns error if request with same UID already exists. This operation also starts the request.
	AddRequest(req DrainRequest) error
	// GetRequest returns DrainRequest with provided UID or nil if request was not found.
	GetRequest(uid string) DrainRequest
	// RemoveRequest removes request with given UID from manager. The operation also cancels the drain request before removal.
	// Operation is blocking until DrainRequest is canceled and drain operation exits.
	RemoveRequest(uid string)
	// ListRequests lists current DrainRequest in manager.
	ListRequests() []DrainRequest
}

Manager is an interface to Manage DrainRequests

func NewManager

func NewManager(log logr.Logger, ctx context.Context, kInterface kubernetes.Interface) Manager

NewManager creates a new Manager

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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