Documentation ¶
Index ¶
- func CreateNodeNameToInfoMap(pods []*v1.Pod, nodes []*v1.Node) map[string]*NodeInfo
- func ReconcileAffinity(pod *v1.Pod) *v1.Affinity
- type Cache
- type NodeInfo
- func (n *NodeInfo) AllocatableResource() Resource
- func (n *NodeInfo) AllowedPodNumber() int
- func (n *NodeInfo) Clone() *NodeInfo
- func (n *NodeInfo) DiskPressureCondition() v1.ConditionStatus
- func (n *NodeInfo) MemoryPressureCondition() v1.ConditionStatus
- func (n *NodeInfo) Node() *v1.Node
- func (n *NodeInfo) NonZeroRequest() Resource
- func (n *NodeInfo) Pods() []*v1.Pod
- func (n *NodeInfo) PodsWithAffinity() []*v1.Pod
- func (n *NodeInfo) RemoveNode(node *v1.Node) error
- func (n *NodeInfo) RequestedResource() Resource
- func (n *NodeInfo) SetNode(node *v1.Node) error
- func (n *NodeInfo) String() string
- func (n *NodeInfo) Taints() ([]v1.Taint, error)
- type Resource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateNodeNameToInfoMap ¶
CreateNodeNameToInfoMap obtains a list of pods and pivots that list into a map where the keys are node names and the values are the aggregated information for that node.
func ReconcileAffinity ¶ added in v1.6.0
Reconcile api and annotation affinity definitions. When alpha affinity feature is not enabled, always take affinity from PodSpec.When alpha affinity feature is enabled, if affinity is not set in PodSpec, take affinity from annotation. When alpha affinity feature is enabled, if affinity is set in PodSpec, take node affinity, pod affinity, and pod anti-affinity individually using the following rule: take affinity from PodSpec if it is defined, otherwise take from annotation if it is defined. TODO: remove when alpha support for affinity is removed
Types ¶
type Cache ¶
type Cache interface { // AssumePod assumes a pod scheduled and aggregates the pod's information into its node. // The implementation also decides the policy to expire pod before being confirmed (receiving Add event). // After expiration, its information would be subtracted. AssumePod(pod *v1.Pod) error // FinishBinding signals that cache for assumed pod can be expired FinishBinding(pod *v1.Pod) error // ForgetPod removes an assumed pod from cache. ForgetPod(pod *v1.Pod) error // AddPod either confirms a pod if it's assumed, or adds it back if it's expired. // If added back, the pod's information would be added again. AddPod(pod *v1.Pod) error // UpdatePod removes oldPod's information and adds newPod's information. UpdatePod(oldPod, newPod *v1.Pod) error // RemovePod removes a pod. The pod's information would be subtracted from assigned node. RemovePod(pod *v1.Pod) error // AddNode adds overall information about node. AddNode(node *v1.Node) error // UpdateNode updates overall information about node. UpdateNode(oldNode, newNode *v1.Node) error // RemoveNode removes overall information about node. RemoveNode(node *v1.Node) error // UpdateNodeNameToInfoMap updates the passed infoMap to the current contents of Cache. // The node info contains aggregated information of pods scheduled (including assumed to be) // on this node. UpdateNodeNameToInfoMap(infoMap map[string]*NodeInfo) error // List lists all cached pods (including assumed ones). List(labels.Selector) ([]*v1.Pod, error) }
Cache collects pods' information and provides node-level aggregated information. It's intended for generic scheduler to do efficient lookup. Cache's operations are pod centric. It does incremental updates based on pod events. Pod events are sent via network. We don't have guaranteed delivery of all events: We use Reflector to list and watch from remote. Reflector might be slow and do a relist, which would lead to missing events.
State Machine of a pod's events in scheduler's cache:
+-------------------------------------------+ +----+ | Add | | | | | | | Update + Assume Add v v |
Initial +--------> Assumed +------------+---> Added <--+
^ + + | + | | | | | | | | Add | | Remove | | | | | | | | + | +----------------+ +-----------> Expired +----> Deleted Forget Expire
Note that an assumed pod can expire, because if we haven't received Add event notifying us for a while, there might be some problems and we shouldn't keep the pod in cache anymore.
Note that "Initial", "Expired", and "Deleted" pods do not actually exist in cache. Based on existing use cases, we are making the following assumptions:
- No pod would be assumed twice
- A pod could be added without going through scheduler. In this case, we will see Add but not Assume event.
- If a pod wasn't added, it wouldn't be removed or updated.
- Both "Expired" and "Deleted" are valid end states. In case of some problems, e.g. network issue, a pod might have changed its state (e.g. added and deleted) without delivering notification to the cache.
type NodeInfo ¶
type NodeInfo struct {
// contains filtered or unexported fields
}
NodeInfo is node level aggregated information.
func NewNodeInfo ¶
NewNodeInfo returns a ready to use empty NodeInfo object. If any pods are given in arguments, their information will be aggregated in the returned object.
func (*NodeInfo) AllocatableResource ¶ added in v1.4.2
AllocatableResource returns allocatable resources on a given node.
func (*NodeInfo) AllowedPodNumber ¶ added in v1.4.2
func (*NodeInfo) DiskPressureCondition ¶ added in v1.6.0
func (n *NodeInfo) DiskPressureCondition() v1.ConditionStatus
func (*NodeInfo) MemoryPressureCondition ¶ added in v1.6.0
func (n *NodeInfo) MemoryPressureCondition() v1.ConditionStatus
func (*NodeInfo) NonZeroRequest ¶
NonZeroRequest returns aggregated nonzero resource request of pods on this node.
func (*NodeInfo) PodsWithAffinity ¶ added in v1.4.2
PodsWithAffinity return all pods with (anti)affinity constraints on this node.
func (*NodeInfo) RemoveNode ¶ added in v1.3.0
Removes the overall information about the node.
func (*NodeInfo) RequestedResource ¶
RequestedResource returns aggregated resource request of pods on this node.
type Resource ¶
type Resource struct { MilliCPU int64 Memory int64 NvidiaGPU int64 OpaqueIntResources map[v1.ResourceName]int64 }
Resource is a collection of compute resource.
func (*Resource) AddOpaque ¶ added in v1.6.0
func (r *Resource) AddOpaque(name v1.ResourceName, quantity int64)
func (*Resource) ResourceList ¶ added in v1.5.1
func (r *Resource) ResourceList() v1.ResourceList