simulator

package
v0.0.0-...-386b7fa Latest Latest
Warning

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

Go to latest
Published: May 14, 2019 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNodeInfoForNode

func BuildNodeInfoForNode(node *apiv1.Node, listers kube_util.ListerRegistry) (*schedulernodeinfo.NodeInfo, errors.AutoscalerError)

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

func DetailedGetPodsForMove

func DetailedGetPodsForMove(nodeInfo *schedulernodeinfo.NodeInfo, skipNodesWithSystemPods bool,
	skipNodesWithLocalStorage bool, listers kube_util.ListerRegistry, minReplicaCount int32,
	pdbs []*policyv1.PodDisruptionBudget) ([]*apiv1.Pod, error)

DetailedGetPodsForMove returns a list of pods that should be moved elsewhere if the node is drained. Raises error if there is an unreplicated pod. Based on kubectl drain code. It checks whether RC, DS, Jobs and RS that created these pods still exist.

func FastGetPodsToMove

func FastGetPodsToMove(nodeInfo *schedulernodeinfo.NodeInfo, skipNodesWithSystemPods bool, skipNodesWithLocalStorage bool,
	pdbs []*policyv1.PodDisruptionBudget) ([]*apiv1.Pod, error)

FastGetPodsToMove returns a list of pods that should be moved elsewhere if the node is drained. Raises error if there is an unreplicated pod. Based on kubectl drain code. It makes an assumption that RC, DS, Jobs and RS were deleted along with their pods (no abandoned pods with dangling created-by annotation). Useful for fast checks.

func FindEmptyNodesToRemove

func FindEmptyNodesToRemove(candidates []*apiv1.Node, pods []*apiv1.Pod) []*apiv1.Node

FindEmptyNodesToRemove finds empty nodes that can be removed.

func GetRequiredPodsForNode

func GetRequiredPodsForNode(nodename string, listers kube_util.ListerRegistry) ([]*apiv1.Pod, errors.AutoscalerError)

GetRequiredPodsForNode returns a list of pods that would appear on the node if the node was just created (like daemonset and manifest-run pods). It reuses kubectl drain command to get the list.

func IsNodeReadyAndSchedulablePredicate

func IsNodeReadyAndSchedulablePredicate(pod *apiv1.Pod, meta predicates.PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) (bool,
	[]predicates.PredicateFailureReason, error)

IsNodeReadyAndSchedulablePredicate checks if node is ready.

func RemoveNodeFromTracker

func RemoveNodeFromTracker(tracker *UsageTracker, node string, utilization map[string]time.Time)

RemoveNodeFromTracker removes node from tracker and also cleans the passed utilization map.

Types

type NoOpEventRecorder

type NoOpEventRecorder struct{}

NoOpEventRecorder is a noop implementation of EventRecorder

func (NoOpEventRecorder) AnnotatedEventf

func (NoOpEventRecorder) AnnotatedEventf(object runtime.Object, annotations map[string]string, eventtype, reason, messageFmt string, args ...interface{})

AnnotatedEventf is a noop method implementation

func (NoOpEventRecorder) Event

func (NoOpEventRecorder) Event(object runtime.Object, eventtype, reason, message string)

Event is a noop method implementation

func (NoOpEventRecorder) Eventf

func (NoOpEventRecorder) Eventf(object runtime.Object, eventtype, reason, messageFmt string, args ...interface{})

Eventf is a noop method implementation

func (NoOpEventRecorder) PastEventf

func (NoOpEventRecorder) PastEventf(object runtime.Object, timestamp metav1.Time, eventtype, reason, messageFmt string, args ...interface{})

PastEventf is a noop method implementation

type NodeToBeRemoved

type NodeToBeRemoved struct {
	// Node to be removed.
	Node *apiv1.Node
	// PodsToReschedule contains pods on the node that should be rescheduled elsewhere.
	PodsToReschedule []*apiv1.Pod
}

NodeToBeRemoved contain information about a node that can be removed.

func FindNodesToRemove

func FindNodesToRemove(candidates []*apiv1.Node, allNodes []*apiv1.Node, pods []*apiv1.Pod,
	listers kube_util.ListerRegistry, predicateChecker *PredicateChecker, maxCount int,
	fastCheck bool, oldHints map[string]string, usageTracker *UsageTracker,
	timestamp time.Time,
	podDisruptionBudgets []*policyv1.PodDisruptionBudget,
) (nodesToRemove []NodeToBeRemoved, unremovableNodes []*apiv1.Node, podReschedulingHints map[string]string, finalError errors.AutoscalerError)

FindNodesToRemove finds nodes that can be removed. Returns also an information about good rescheduling location for each of the pods.

type PredicateChecker

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

PredicateChecker checks whether all required predicates pass for given Pod and Node.

func NewCustomTestPredicateChecker

func NewCustomTestPredicateChecker(predicateInfos []PredicateInfo) *PredicateChecker

NewCustomTestPredicateChecker builds test version of PredicateChecker with additional predicates. Helps with benchmarking different ordering of predicates.

func NewPredicateChecker

func NewPredicateChecker(kubeClient kube_client.Interface, stop <-chan struct{}) (*PredicateChecker, error)

NewPredicateChecker builds PredicateChecker.

func NewTestPredicateChecker

func NewTestPredicateChecker() *PredicateChecker

NewTestPredicateChecker builds test version of PredicateChecker.

func (*PredicateChecker) CheckPredicates

func (p *PredicateChecker) CheckPredicates(pod *apiv1.Pod, predicateMetadata predicates.PredicateMetadata, nodeInfo *schedulernodeinfo.NodeInfo) *PredicateError

CheckPredicates checks if the given pod can be placed on the given node. To improve performance predicateMetadata can be calculated using GetPredicateMetadata method and passed to CheckPredicates, however, this may lead to incorrect results if it was calculated using NodeInfo map representing different cluster state and the performance gains of CheckPredicates won't always offset the cost of GetPredicateMetadata. Alternatively you can pass nil as predicateMetadata.

func (*PredicateChecker) FitsAny

func (p *PredicateChecker) FitsAny(pod *apiv1.Pod, nodeInfos map[string]*schedulernodeinfo.NodeInfo) (string, error)

FitsAny checks if the given pod can be place on any of the given nodes.

func (*PredicateChecker) GetPredicateMetadata

func (p *PredicateChecker) GetPredicateMetadata(pod *apiv1.Pod, nodeInfos map[string]*schedulernodeinfo.NodeInfo) predicates.PredicateMetadata

GetPredicateMetadata precomputes some information useful for running predicates on a given pod in a given state of the cluster (represented by nodeInfos map). Passing the result of this function to CheckPredicates can significantly improve the performance of running predicates, especially MatchInterPodAffinity predicate. However, calculating predicateMetadata is also quite expensive, so it's not always the best option to run this method. Please refer to https://github.com/kubernetes/autoscaler/issues/257 for more details.

func (*PredicateChecker) IsAffinityPredicateEnabled

func (p *PredicateChecker) IsAffinityPredicateEnabled() bool

IsAffinityPredicateEnabled checks if affinity predicate is enabled.

func (*PredicateChecker) SetAffinityPredicateEnabled

func (p *PredicateChecker) SetAffinityPredicateEnabled(enable bool)

SetAffinityPredicateEnabled can be used to enable or disable checking MatchInterPodAffinity predicate. This will cause incorrect CA behavior if there is at least a single pod in cluster using affinity/antiaffinity. However, checking affinity predicate is extremely costly even if no pod is using it, so it may be worth disabling it in such situation.

type PredicateError

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

PredicateError implements error, preserving the original error information from scheduler predicate.

func NewPredicateError

func NewPredicateError(name string, err error, reasons []string, originalReasons []predicates.PredicateFailureReason) *PredicateError

NewPredicateError creates a new predicate error from error and reasons.

func (*PredicateError) Error

func (pe *PredicateError) Error() string

Error returns a predefined error message.

func (*PredicateError) OriginalReasons

func (pe *PredicateError) OriginalReasons() []predicates.PredicateFailureReason

OriginalReasons returns original failure reasons from failed predicate as a slice of PredicateFailureReason.

func (*PredicateError) PredicateName

func (pe *PredicateError) PredicateName() string

PredicateName returns the name of failed predicate.

func (*PredicateError) Reasons

func (pe *PredicateError) Reasons() []string

Reasons returns original failure reasons from failed predicate as a slice of strings.

func (*PredicateError) VerboseError

func (pe *PredicateError) VerboseError() string

VerboseError generates verbose error message if it isn't yet done. We're running a ton of predicates and more often than not we only care whether they pass or not and don't care for a reason. Turns out formatting nice error messages gets very expensive, so we only do it if explicitly requested.

type PredicateInfo

type PredicateInfo struct {
	Name      string
	Predicate predicates.FitPredicate
}

PredicateInfo assigns a name to a predicate

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

type UtilizationInfo

type UtilizationInfo struct {
	CpuUtil float64
	MemUtil float64
	GpuUtil float64
	// Resource name of highest utilization resource
	ResourceName apiv1.ResourceName
	// Max(CpuUtil, MemUtil) or GpuUtils
	Utilization float64
}

UtilizationInfo contains utilization information for a node.

func CalculateUtilization

func CalculateUtilization(node *apiv1.Node, nodeInfo *schedulernodeinfo.NodeInfo, skipDaemonSetPods, skipMirrorPods bool, gpuLabel string) (utilInfo UtilizationInfo, err error)

CalculateUtilization calculates utilization of a node, defined as maximum of (cpu, memory) or gpu utilization based on if the node has GPU or not. Per resource utilization is the sum of requests for it divided by allocatable. It also returns the individual cpu, memory and gpu utilization.

Jump to

Keyboard shortcuts

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