simulator

package
v0.0.0-...-0c26da3 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 22 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNodeInfoForNode

func BuildNodeInfoForNode(node *apiv1.Node, scheduledPods []*apiv1.Pod, daemonsets []*appsv1.DaemonSet, forceDaemonSets bool) (*schedulerframework.NodeInfo, errors.AutoscalerError)

BuildNodeInfoForNode build a NodeInfo structure for the given node as if the node was just created.

func GetPodsToMove

func GetPodsToMove(nodeInfo *schedulerframework.NodeInfo, deleteOptions options.NodeDeleteOptions, drainabilityRules rules.Rules, listers kube_util.ListerRegistry, remainingPdbTracker pdb.RemainingPdbTracker, timestamp time.Time) (pods []*apiv1.Pod, daemonSetPods []*apiv1.Pod, blockingPod *drain.BlockingPod, err error)

GetPodsToMove returns a list of pods that should be moved elsewhere and a list of DaemonSet pods that should be evicted if the node is drained. Raises error if there is an unreplicated pod. Based on kubectl drain code. If listers is nil it makes an assumption that RC, DS, Jobs and RS were deleted along with their pods (no abandoned pods with dangling created-by annotation). If listers is not nil it checks whether RC, DS, Jobs and RS that created these pods still exist.

func RemoveNodeFromTracker

func RemoveNodeFromTracker(tracker *UsageTracker, node string, unneeded []string) []string

RemoveNodeFromTracker removes node from tracker and returns node names that should be removed from the list of uneeded nodes.

Types

type NodeToBeRemoved

type NodeToBeRemoved struct {
	// Node to be removed.
	Node *apiv1.Node
	// IsRisky indicates that node has high chance to fail during removal.
	IsRisky bool
	// PodsToReschedule contains pods on the node that should be rescheduled elsewhere.
	PodsToReschedule []*apiv1.Pod
	DaemonSetPods    []*apiv1.Pod
}

NodeToBeRemoved contain information about a node that can be removed.

type RemovalSimulator

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

RemovalSimulator is a helper object for simulating node removal scenarios.

func NewRemovalSimulator

func NewRemovalSimulator(listers kube_util.ListerRegistry, clusterSnapshot clustersnapshot.ClusterSnapshot, predicateChecker predicatechecker.PredicateChecker,
	usageTracker *UsageTracker, deleteOptions options.NodeDeleteOptions, drainabilityRules rules.Rules, persistSuccessfulSimulations bool) *RemovalSimulator

NewRemovalSimulator returns a new RemovalSimulator.

func (*RemovalSimulator) DropOldHints

func (r *RemovalSimulator) DropOldHints()

DropOldHints drops old scheduling hints.

func (*RemovalSimulator) FindEmptyNodesToRemove

func (r *RemovalSimulator) FindEmptyNodesToRemove(candidates []string, timestamp time.Time) []string

FindEmptyNodesToRemove finds empty nodes that can be removed.

func (*RemovalSimulator) FindNodesToRemove

func (r *RemovalSimulator) FindNodesToRemove(
	candidates []string,
	destinations []string,
	timestamp time.Time,
	remainingPdbTracker pdb.RemainingPdbTracker,
) (nodesToRemove []NodeToBeRemoved, unremovableNodes []*UnremovableNode)

FindNodesToRemove finds nodes that can be removed.

func (*RemovalSimulator) SimulateNodeRemoval

func (r *RemovalSimulator) SimulateNodeRemoval(
	nodeName string,
	destinationMap map[string]bool,
	timestamp time.Time,
	remainingPdbTracker pdb.RemainingPdbTracker,
) (*NodeToBeRemoved, *UnremovableNode)

SimulateNodeRemoval simulates removing a node from the cluster to check whether it is possible to move its pods. Depending on the outcome, exactly one of (NodeToBeRemoved, UnremovableNode) will be populated in the return value, the other will be nil.

type UnremovableNode

type UnremovableNode struct {
	Node        *apiv1.Node
	Reason      UnremovableReason
	BlockingPod *drain.BlockingPod
}

UnremovableNode represents a node that can't be removed by CA.

type UnremovableReason

type UnremovableReason int

UnremovableReason represents a reason why a node can't be removed by CA.

const (
	// NoReason - sanity check, this should never be set explicitly. If this is found in the wild, it means that it was
	// implicitly initialized and might indicate a bug.
	NoReason UnremovableReason = iota
	// ScaleDownDisabledAnnotation - node can't be removed because it has a "scale down disabled" annotation.
	ScaleDownDisabledAnnotation
	// ScaleDownUnreadyDisabled - node can't be removed because it is unready and scale down is disabled for unready nodes.
	ScaleDownUnreadyDisabled
	// NotAutoscaled - node can't be removed because it doesn't belong to an autoscaled node group.
	NotAutoscaled
	// NotUnneededLongEnough - node can't be removed because it wasn't unneeded for long enough.
	NotUnneededLongEnough
	// NotUnreadyLongEnough - node can't be removed because it wasn't unready for long enough.
	NotUnreadyLongEnough
	// NodeGroupMinSizeReached - node can't be removed because its node group is at its minimal size already.
	NodeGroupMinSizeReached
	// MinimalResourceLimitExceeded - node can't be removed because it would violate cluster-wide minimal resource limits.
	MinimalResourceLimitExceeded
	// CurrentlyBeingDeleted - node can't be removed because it's already in the process of being deleted.
	CurrentlyBeingDeleted
	// NotUnderutilized - node can't be removed because it's not underutilized.
	NotUnderutilized
	// NotUnneededOtherReason - node can't be removed because it's not marked as unneeded for other reasons (e.g. it wasn't inspected at all in a given autoscaler loop).
	NotUnneededOtherReason
	// RecentlyUnremovable - node can't be removed because it was recently found to be unremovable.
	RecentlyUnremovable
	// NoPlaceToMovePods - node can't be removed because there's no place to move its pods to.
	NoPlaceToMovePods
	// BlockedByPod - node can't be removed because a pod running on it can't be moved. The reason why should be in BlockingPod.
	BlockedByPod
	// UnexpectedError - node can't be removed because of an unexpected error.
	UnexpectedError
)

type UsageRecord

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

UsageRecord records which node was considered helpful to which node during pod rescheduling analysis.

type UsageTracker

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

UsageTracker track usage relationship between nodes in pod rescheduling calculations.

func NewUsageTracker

func NewUsageTracker() *UsageTracker

NewUsageTracker builds new usage tracker.

func (*UsageTracker) CleanUp

func (tracker *UsageTracker) CleanUp(cutoff time.Time)

CleanUp removes all relations updated before the cutoff time.

func (*UsageTracker) Get

func (tracker *UsageTracker) Get(node string) (data *UsageRecord, found bool)

Get gets the given node UsageRecord, if present

func (*UsageTracker) RegisterUsage

func (tracker *UsageTracker) RegisterUsage(nodeA string, nodeB string, timestamp time.Time)

RegisterUsage registers that node A uses nodeB during usage calculations at time timestamp.

func (*UsageTracker) Unregister

func (tracker *UsageTracker) Unregister(node string)

Unregister removes the given node from all usage records

Jump to

Keyboard shortcuts

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