simulator

package
v0.0.0-...-73e42e7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2020 License: Apache-2.0 Imports: 23 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.AutorepairError)

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

func CalculateUtilization

func CalculateUtilization(node *apiv1.Node, nodeInfo *schedulercache.NodeInfo) (float64, error)

CalculateUtilization calculates utilization of a node, defined as total amount of requested resources divided by capacity.

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). Usefull 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.AutorepairError)

GetRequiredPodsForNode returns a list od 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 ErrorVerbosity

type ErrorVerbosity bool

ErrorVerbosity defines the verbosity of error messages returned by PredicateChecker

const (
	// ReturnVerboseError causes informative error messages to be returned.
	ReturnVerboseError ErrorVerbosity = true
	// ReturnSimpleError causes simple, detail-free error messages to be returned.
	// This significantly improves performance and is useful if the error message
	// is discarded anyway.
	ReturnSimpleError ErrorVerbosity = false
)

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.

type PredicateChecker

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

PredicateChecker checks whether all required predicates are matched 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, verbosity ErrorVerbosity) error

CheckPredicates checks if the given pod can be placed on the given node. 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 verbose is set to ReturnVerboseError. 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 extremly costly even if no pod is using it, so it may be worth disabling it in such situation.

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