Documentation
¶
Index ¶
- func CreateNodeNameToInfoMap(pods []*v1.Pod, nodes []*v1.Node) map[string]*NodeInfo
- type Cache
- type ImageStateSummary
- type NodeInfo
- func (n *NodeInfo) AddPod(pod *v1.Pod)
- func (n *NodeInfo) AllocatableResource() Resource
- func (n *NodeInfo) AllowedPodNumber() int
- func (n *NodeInfo) Clone() *NodeInfo
- func (n *NodeInfo) DiskPressureCondition() v1.ConditionStatus
- func (n *NodeInfo) Filter(pod *v1.Pod) bool
- func (n *NodeInfo) FilterOutPods(pods []*v1.Pod) []*v1.Pod
- func (n *NodeInfo) ImageStates() map[string]*ImageStateSummary
- func (n *NodeInfo) MemoryPressureCondition() v1.ConditionStatus
- func (n *NodeInfo) Node() *v1.Node
- func (n *NodeInfo) NonZeroRequest() Resource
- func (n *NodeInfo) PIDPressureCondition() v1.ConditionStatus
- func (n *NodeInfo) Pods() []*v1.Pod
- func (n *NodeInfo) PodsWithAffinity() []*v1.Pod
- func (n *NodeInfo) RemoveNode(node *v1.Node) error
- func (n *NodeInfo) RemovePod(pod *v1.Pod) error
- func (n *NodeInfo) RequestedResource() Resource
- func (n *NodeInfo) SetAllocatableResource(allocatableResource *Resource)
- func (n *NodeInfo) SetNode(node *v1.Node) error
- func (n *NodeInfo) String() string
- func (n *NodeInfo) Taints() ([]v1.Taint, error)
- func (n *NodeInfo) UsedPorts() util.HostPortInfo
- func (n *NodeInfo) VolumeLimits() map[v1.ResourceName]int64
- type NodeTree
- type PodFilter
- type Resource
- func (r *Resource) Add(rl v1.ResourceList)
- func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)
- func (r *Resource) Clone() *Resource
- func (r *Resource) ResourceList() v1.ResourceList
- func (r *Resource) SetMaxResource(rl v1.ResourceList)
- func (r *Resource) SetScalar(name v1.ResourceName, quantity int64)
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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 // GetPod returns the pod from the cache with the same namespace and the // same name of the specified pod. GetPod(pod *v1.Pod) (*v1.Pod, error) // IsAssumedPod returns true if the pod is assumed and not expired. IsAssumedPod(pod *v1.Pod) (bool, 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 // AddPDB adds a PodDisruptionBudget object to the cache. AddPDB(pdb *policy.PodDisruptionBudget) error // UpdatePDB updates a PodDisruptionBudget object in the cache. UpdatePDB(oldPDB, newPDB *policy.PodDisruptionBudget) error // RemovePDB removes a PodDisruptionBudget object from the cache. RemovePDB(pdb *policy.PodDisruptionBudget) error // List lists all cached PDBs matching the selector. ListPDBs(selector labels.Selector) ([]*policy.PodDisruptionBudget, 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) // FilteredList returns all cached pods that pass the filter. FilteredList(filter PodFilter, selector labels.Selector) ([]*v1.Pod, error) // Snapshot takes a snapshot on current cache Snapshot() *Snapshot // IsUpToDate returns true if the given NodeInfo matches the current data in the cache. IsUpToDate(n *NodeInfo) bool // NodeTree returns a node tree structure NodeTree() *NodeTree }
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 ImageStateSummary ¶ added in v1.12.6
type ImageStateSummary struct { // Size of the image Size int64 // Used to track how many nodes have this image NumNodes int }
ImageStateSummary provides summarized information about the state of an image.
type NodeInfo ¶
type NodeInfo struct { // TransientInfo holds the information pertaining to a scheduling cycle. This will be destructed at the end of // scheduling cycle. // TODO: @ravig. Remove this once we have a clear approach for message passing across predicates and priorities. TransientInfo *transientSchedulerInfo // 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 ¶
AllocatableResource returns allocatable resources on a given node.
func (*NodeInfo) AllowedPodNumber ¶
AllowedPodNumber returns the number of the allowed pods on this node.
func (*NodeInfo) DiskPressureCondition ¶
func (n *NodeInfo) DiskPressureCondition() v1.ConditionStatus
DiskPressureCondition returns the disk pressure condition status on this node.
func (*NodeInfo) Filter ¶
Filter implements PodFilter interface. It returns false only if the pod node name matches NodeInfo.node and the pod is not found in the pods list. Otherwise, returns true.
func (*NodeInfo) FilterOutPods ¶
FilterOutPods receives a list of pods and filters out those whose node names are equal to the node of this NodeInfo, but are not found in the pods of this NodeInfo.
Preemption logic simulates removal of pods on a node by removing them from the corresponding NodeInfo. In order for the simulation to work, we call this method on the pods returned from SchedulerCache, so that predicate functions see only the pods that are not removed from the NodeInfo.
func (*NodeInfo) ImageStates ¶ added in v1.12.6
func (n *NodeInfo) ImageStates() map[string]*ImageStateSummary
ImageStates returns the state information of all images.
func (*NodeInfo) MemoryPressureCondition ¶
func (n *NodeInfo) MemoryPressureCondition() v1.ConditionStatus
MemoryPressureCondition returns the memory pressure condition status on this node.
func (*NodeInfo) NonZeroRequest ¶
NonZeroRequest returns aggregated nonzero resource request of pods on this node.
func (*NodeInfo) PIDPressureCondition ¶
func (n *NodeInfo) PIDPressureCondition() v1.ConditionStatus
PIDPressureCondition returns the pid pressure condition status on this node.
func (*NodeInfo) PodsWithAffinity ¶
PodsWithAffinity return all pods with (anti)affinity constraints on this node.
func (*NodeInfo) RemoveNode ¶
RemoveNode removes the overall information about the node.
func (*NodeInfo) RequestedResource ¶
RequestedResource returns aggregated resource request of pods on this node.
func (*NodeInfo) SetAllocatableResource ¶
SetAllocatableResource sets the allocatableResource information of given node.
func (*NodeInfo) UsedPorts ¶
func (n *NodeInfo) UsedPorts() util.HostPortInfo
UsedPorts returns used ports on this node.
func (*NodeInfo) VolumeLimits ¶
func (n *NodeInfo) VolumeLimits() map[v1.ResourceName]int64
VolumeLimits returns volume limits associated with the node
type NodeTree ¶ added in v1.12.6
type NodeTree struct { NumNodes int // contains filtered or unexported fields }
NodeTree is a tree-like data structure that holds node names in each zone. Zone names are keys to "NodeTree.tree" and values of "NodeTree.tree" are arrays of node names.
func (*NodeTree) AddNode ¶ added in v1.12.6
AddNode adds a node and its corresponding zone to the tree. If the zone already exists, the node is added to the array of nodes in that zone.
func (*NodeTree) Next ¶ added in v1.12.6
Next returns the name of the next node. NodeTree iterates over zones and in each zone iterates over nodes in a round robin fashion.
func (*NodeTree) RemoveNode ¶ added in v1.12.6
RemoveNode removes a node from the NodeTree.
func (*NodeTree) UpdateNode ¶ added in v1.12.6
UpdateNode updates a node in the NodeTree.
type PodFilter ¶
PodFilter is a function to filter a pod. If pod passed return true else return false.
type Resource ¶
type Resource struct { MilliCPU int64 Memory int64 EphemeralStorage int64 // We store allowedPodNumber (which is Node.Status.Allocatable.Pods().Value()) // explicitly as int, to avoid conversions and improve performance. AllowedPodNumber int // ScalarResources ScalarResources map[v1.ResourceName]int64 }
Resource is a collection of compute resource.
func NewResource ¶
func NewResource(rl v1.ResourceList) *Resource
NewResource creates a Resource from ResourceList
func (*Resource) Add ¶
func (r *Resource) Add(rl v1.ResourceList)
Add adds ResourceList into Resource.
func (*Resource) AddScalar ¶
func (r *Resource) AddScalar(name v1.ResourceName, quantity int64)
AddScalar adds a resource by a scalar value of this resource.
func (*Resource) ResourceList ¶
func (r *Resource) ResourceList() v1.ResourceList
ResourceList returns a resource list of this resource.
func (*Resource) SetMaxResource ¶
func (r *Resource) SetMaxResource(rl v1.ResourceList)
SetMaxResource compares with ResourceList and takes max value for each Resource.