simulator

package
v0.0.0-...-93f75fa Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2016 License: Apache-2.0 Imports: 17 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, error)

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) ([]*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 and force option was not specified. 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) ([]*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 and force option was not specified. 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. Doesn't check i

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, error)

GetRequiredPodsForNode returns a list od pods that would appear on the node if the node was just created (like deamonset 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) (nodesToRemove []NodeToBeRemoved, podReschedulingHints map[string]string, finalError error)

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 are matched for given Pod and Node

func NewPredicateChecker

func NewPredicateChecker(kubeClient kube_client.Interface) (*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, nodeInfo *schedulercache.NodeInfo) error

CheckPredicates checks if the given pod can be placed on the given node.

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.

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