simulator

package
v0.0.0-...-7df4f84 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: Apache-2.0 Imports: 24 Imported by: 104

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPodsToMove

func GetPodsToMove(nodeInfo *framework.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 NodeInfoSanitizedDeepCopy

func NodeInfoSanitizedDeepCopy(template *framework.NodeInfo, suffix string) *framework.NodeInfo

NodeInfoSanitizedDeepCopy duplicates the provided template NodeInfo, returning a fresh NodeInfo that can be injected into the cluster snapshot. The NodeInfo is sanitized (names, UIDs are changed, etc.), so that it can be injected along other copies created from the same template.

func SanitizedTemplateNodeInfoFromNodeGroup

func SanitizedTemplateNodeInfoFromNodeGroup(nodeGroup nodeGroupTemplateNodeInfoGetter, daemonsets []*appsv1.DaemonSet, taintConfig taints.TaintConfig) (*framework.NodeInfo, errors.AutoscalerError)

SanitizedTemplateNodeInfoFromNodeGroup returns a template NodeInfo object based on NodeGroup.TemplateNodeInfo(). The template is sanitized, and only contains the pods that should appear on a new Node from the same node group (e.g. DaemonSet pods).

func SanitizedTemplateNodeInfoFromNodeInfo

func SanitizedTemplateNodeInfoFromNodeInfo(example *framework.NodeInfo, nodeGroupId string, daemonsets []*appsv1.DaemonSet, forceDaemonSets bool, taintConfig taints.TaintConfig) (*framework.NodeInfo, errors.AutoscalerError)

SanitizedTemplateNodeInfoFromNodeInfo returns a template NodeInfo object based on a real example NodeInfo from the cluster. The template is sanitized, and only contains the pods that should appear on a new Node from the same node group (e.g. DaemonSet pods).

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, 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
	// NodeGroupMaxDeletionCountReached - node can't be removed because max node count to be removed value set in planner reached
	NodeGroupMaxDeletionCountReached
	// AtomicScaleDownFailed - node can't be removed as node group has ZeroOrMaxNodeScaling enabled and number of nodes to remove are not equal to target size
	AtomicScaleDownFailed
	// 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
)

Jump to

Keyboard shortcuts

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