simulator

package
v0.0.0-...-503a17f Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2018 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildNodeInfoForNode

func BuildNodeInfoForNode(node *apiv1.Node, client kube_client.Interface) (*schedulercache.NodeInfo, errors.AutoscalerError)

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

func DetailedGetPodsForMove

func DetailedGetPodsForMove(nodeInfo *schedulercache.NodeInfo, skipNodesWithSystemPods bool,
	skipNodesWithLocalStorage bool, client client.Interface, 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 *schedulercache.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, client kube_client.Interface) ([]*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 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 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,
	client client.Interface, 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 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 algorithm.PredicateMetadata, nodeInfo *schedulercache.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]*schedulercache.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]*schedulercache.NodeInfo) algorithm.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 []algorithm.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() []algorithm.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 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
	// Max(CpuUtil, MemUtil).
	Utilization float64
}

UtilizationInfo contains utilization information for a node.

func CalculateUtilization

func CalculateUtilization(node *apiv1.Node, nodeInfo *schedulercache.NodeInfo) (utilInfo UtilizationInfo, err error)

CalculateUtilization calculates utilization of a node, defined as maximum of (cpu, memory) utilization. Per resource utilization is the sum of requests for it divided by allocatable. It also returns the individual cpu and memory utilization.

Jump to

Keyboard shortcuts

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