Documentation
¶
Index ¶
- Constants
- Variables
- func AllClusterEventLabels() []string
- func ClusterEventIsWildCard(ce fwk.ClusterEvent) bool
- func GetNamespacedName(namespace, name string) string
- func GetPodKey(pod *v1.Pod) (string, error)
- func MatchAnyClusterEvent(ce fwk.ClusterEvent, incomingEvents []fwk.ClusterEvent) bool
- func MatchClusterEvents(ce, incomingEvent fwk.ClusterEvent) bool
- func NewPostFilterResultWithNominatedNode(name string) *fwk.PostFilterResult
- func NodeSchedulingPropertiesChange(newNode *v1.Node, oldNode *v1.Node) (events []fwk.ClusterEvent)
- func PodSchedulingPropertiesChange(newPod *v1.Pod, oldPod *v1.Pod) (events []fwk.ClusterEvent)
- func UnrollWildCardResource() []fwk.ClusterEventWithHint
- type CycleState
- func (c *CycleState) Clone() fwk.CycleState
- func (c *CycleState) Delete(key fwk.StateKey)
- func (c *CycleState) GetSkipFilterPlugins() sets.Set[string]
- func (c *CycleState) GetSkipPreBindPlugins() sets.Set[string]
- func (c *CycleState) GetSkipScorePlugins() sets.Set[string]
- func (c *CycleState) Read(key fwk.StateKey) (fwk.StateData, error)
- func (c *CycleState) SetRecordPluginMetrics(flag bool)
- func (c *CycleState) SetSkipFilterPlugins(plugins sets.Set[string])
- func (c *CycleState) SetSkipPreBindPlugins(plugins sets.Set[string])
- func (c *CycleState) SetSkipScorePlugins(plugins sets.Set[string])
- func (c *CycleState) ShouldRecordPluginMetrics() bool
- func (c *CycleState) Write(key fwk.StateKey, val fwk.StateData)
- type Diagnosis
- type FitError
- type Framework
- type NodeInfo
- func (n *NodeInfo) AddPod(pod *v1.Pod)
- func (n *NodeInfo) AddPodInfo(podInfo fwk.PodInfo)
- func (n *NodeInfo) GetAllocatable() fwk.Resource
- func (n *NodeInfo) GetGeneration() int64
- func (n *NodeInfo) GetImageStates() map[string]*fwk.ImageStateSummary
- func (n *NodeInfo) GetName() string
- func (n *NodeInfo) GetNamespace() string
- func (n *NodeInfo) GetNonZeroRequested() fwk.Resource
- func (n *NodeInfo) GetPVCRefCounts() map[string]int
- func (n *NodeInfo) GetPods() []fwk.PodInfo
- func (n *NodeInfo) GetPodsWithAffinity() []fwk.PodInfo
- func (n *NodeInfo) GetPodsWithRequiredAntiAffinity() []fwk.PodInfo
- func (n *NodeInfo) GetRequested() fwk.Resource
- func (n *NodeInfo) GetUsedPorts() fwk.HostPortInfo
- func (n *NodeInfo) Node() *v1.Node
- func (n *NodeInfo) RemoveNode()
- func (n *NodeInfo) RemovePod(logger klog.Logger, pod *v1.Pod) error
- func (n *NodeInfo) SetNode(node *v1.Node)
- func (n *NodeInfo) Snapshot() fwk.NodeInfo
- func (n *NodeInfo) SnapshotConcrete() *NodeInfo
- func (n *NodeInfo) String() string
- type NodeToStatus
- func (m *NodeToStatus) AbsentNodesStatus() *fwk.Status
- func (m *NodeToStatus) ForEachExplicitNode(fn func(nodeName string, status *fwk.Status))
- func (m *NodeToStatus) Get(nodeName string) *fwk.Status
- func (m *NodeToStatus) Len() int
- func (m *NodeToStatus) NodesForStatusCode(nodeLister fwk.NodeInfoLister, code fwk.Code) ([]fwk.NodeInfo, error)
- func (m *NodeToStatus) Set(nodeName string, status *fwk.Status)
- func (m *NodeToStatus) SetAbsentNodesStatus(status *fwk.Status)
- type PodInfo
- func (pi *PodInfo) CalculateResource() fwk.PodResource
- func (pi *PodInfo) DeepCopy() *PodInfo
- func (pi *PodInfo) GetPod() *v1.Pod
- func (pi *PodInfo) GetPreferredAffinityTerms() []fwk.WeightedAffinityTerm
- func (pi *PodInfo) GetPreferredAntiAffinityTerms() []fwk.WeightedAffinityTerm
- func (pi *PodInfo) GetRequiredAffinityTerms() []fwk.AffinityTerm
- func (pi *PodInfo) GetRequiredAntiAffinityTerms() []fwk.AffinityTerm
- func (pi *PodInfo) Update(pod *v1.Pod) error
- type PodsToActivate
- type QueuedPodInfo
- func (pqi *QueuedPodInfo) DeepCopy() *QueuedPodInfo
- func (pqi *QueuedPodInfo) Gated() bool
- func (pqi *QueuedPodInfo) GetAttempts() int
- func (pqi *QueuedPodInfo) GetBackoffExpiration() time.Time
- func (pqi *QueuedPodInfo) GetConsecutiveErrorsCount() int
- func (pqi *QueuedPodInfo) GetGatingPlugin() string
- func (pqi *QueuedPodInfo) GetGatingPluginEvents() []fwk.ClusterEvent
- func (pqi *QueuedPodInfo) GetInitialAttemptTimestamp() *time.Time
- func (pqi *QueuedPodInfo) GetPendingPlugins() sets.Set[string]
- func (pqi *QueuedPodInfo) GetPodInfo() fwk.PodInfo
- func (pqi *QueuedPodInfo) GetTimestamp() time.Time
- func (pqi *QueuedPodInfo) GetUnschedulableCount() int
- func (pqi *QueuedPodInfo) GetUnschedulablePlugins() sets.Set[string]
- 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) GetAllowedPodNumber() int
- func (r *Resource) GetEphemeralStorage() int64
- func (r *Resource) GetMemory() int64
- func (r *Resource) GetMilliCPU() int64
- func (r *Resource) GetScalarResources() map[v1.ResourceName]int64
- func (r *Resource) SetMaxResource(rl v1.ResourceList)
- func (r *Resource) SetScalar(name v1.ResourceName, quantity int64)
Constants ¶
const ( // ScheduleAttemptFailure is the event when a schedule attempt fails. ScheduleAttemptFailure = "ScheduleAttemptFailure" // BackoffComplete is the event when a pod finishes backoff. BackoffComplete = "BackoffComplete" // PopFromBackoffQ is the event when a pod is popped from backoffQ when activeQ is empty. PopFromBackoffQ = "PopFromBackoffQ" // ForceActivate is the event when a pod is moved from unschedulablePods/backoffQ // to activeQ. Usually it's triggered by plugin implementations. ForceActivate = "ForceActivate" // UnschedulableTimeout is the event when a pod is moved from unschedulablePods // due to the timeout specified at pod-max-in-unschedulable-pods-duration. UnschedulableTimeout = "UnschedulableTimeout" )
Special event labels.
const ExtenderName = "Extender"
ExtenderName is a fake plugin name put in UnschedulablePlugins when Extender rejected some Nodes.
const (
// NoNodeAvailableMsg is used to format message when no nodes available.
NoNodeAvailableMsg = "0/%v nodes are available"
)
Variables ¶
var ( // EventAssignedPodAdd is the event when an assigned pod is added. EventAssignedPodAdd = fwk.ClusterEvent{Resource: assignedPod, ActionType: fwk.Add} // EventAssignedPodUpdate is the event when an assigned pod is updated. EventAssignedPodUpdate = fwk.ClusterEvent{Resource: assignedPod, ActionType: fwk.Update} // EventAssignedPodDelete is the event when an assigned pod is deleted. EventAssignedPodDelete = fwk.ClusterEvent{Resource: assignedPod, ActionType: fwk.Delete} // EventUnscheduledPodAdd is the event when an unscheduled pod is added. EventUnscheduledPodAdd = fwk.ClusterEvent{Resource: unschedulablePod, ActionType: fwk.Add} // EventUnscheduledPodUpdate is the event when an unscheduled pod is updated. EventUnscheduledPodUpdate = fwk.ClusterEvent{Resource: unschedulablePod, ActionType: fwk.Update} // EventUnscheduledPodDelete is the event when an unscheduled pod is deleted. EventUnscheduledPodDelete = fwk.ClusterEvent{Resource: unschedulablePod, ActionType: fwk.Delete} // EventUnschedulableTimeout is the event when a pod stays in unschedulable for longer than timeout. EventUnschedulableTimeout = fwk.ClusterEvent{Resource: fwk.WildCard, ActionType: fwk.All, CustomLabel: UnschedulableTimeout} // EventForceActivate is the event when a pod is moved from unschedulablePods/backoffQ to activeQ. EventForceActivate = fwk.ClusterEvent{Resource: fwk.WildCard, ActionType: fwk.All, CustomLabel: ForceActivate} )
var PodsToActivateKey fwk.StateKey = "kubernetes.io/pods-to-activate"
PodsToActivateKey is a reserved state key for stashing pods. If the stashed pods are present in unschedulablePods or backoffQ,they will be activated (i.e., moved to activeQ) in two phases: - end of a scheduling cycle if it succeeds (will be cleared from `PodsToActivate` if activated) - end of a binding cycle if it succeeds
Functions ¶
func AllClusterEventLabels ¶ added in v1.32.0
func AllClusterEventLabels() []string
AllClusterEventLabels returns all possible cluster event labels given to the metrics.
func ClusterEventIsWildCard ¶ added in v1.34.0
func ClusterEventIsWildCard(ce fwk.ClusterEvent) bool
ClusterEventIsWildCard returns true if the given ClusterEvent follows WildCard semantics
func GetNamespacedName ¶ added in v1.25.0
GetNamespacedName returns the string format of a namespaced resource name.
func MatchAnyClusterEvent ¶ added in v1.34.0
func MatchAnyClusterEvent(ce fwk.ClusterEvent, incomingEvents []fwk.ClusterEvent) bool
func MatchClusterEvents ¶ added in v1.34.0
func MatchClusterEvents(ce, incomingEvent fwk.ClusterEvent) bool
MatchClusterEvents returns true if ce is matched with incomingEvent. "match" means that incomingEvent is the same or more specific than the ce. e.g. when ce.ActionType is Update and incomingEvent.ActionType is UpdateNodeLabel, it will return true because UpdateNodeLabel is more specific than Update. On the other hand, when ce.ActionType is UpdateNodeLabel and incomingEvent.ActionType is Update, it returns false. This is based on the fact that the scheduler interprets the incoming cluster event as specific event as possible; meaning, if incomingEvent is Node/Update, it means that Node's update is not something that can be interpreted as any of Node's specific Update events.
If the ce.Resource is "*", there's no requirement for incomingEvent.Resource. Contrarily, if incomingEvent.Resource is "*", the only accepted ce.Resource is "*" (which should never happen in the current implementation of the scheduling queue).
Note: we have a special case here when incomingEvent is a wildcard event, it will force all Pods to move to activeQ/backoffQ, but we take it as an unmatched event unless ce is also a wildcard event.
func NewPostFilterResultWithNominatedNode ¶ added in v1.23.2
func NewPostFilterResultWithNominatedNode(name string) *fwk.PostFilterResult
func NodeSchedulingPropertiesChange ¶ added in v1.31.0
NodeSchedulingPropertiesChange interprets the update of a node and returns corresponding UpdateNodeXYZ event(s).
func PodSchedulingPropertiesChange ¶ added in v1.31.0
PodSchedulingPropertiesChange interprets the update of a pod and returns corresponding UpdatePodXYZ event(s). Once we have other pod update events, we should update here as well.
func UnrollWildCardResource ¶ added in v1.28.0
func UnrollWildCardResource() []fwk.ClusterEventWithHint
Types ¶
type CycleState ¶
type CycleState struct {
// contains filtered or unexported fields
}
Note: CycleState uses a sync.Map to back the storage, because it is thread safe. It's aimed to optimize for the "write once and read many times" scenarios. It is the recommended pattern used in all in-tree plugins - plugin-specific state is written once in PreFilter/PreScore and afterward read many times in Filter/Score.
func NewCycleState ¶
func NewCycleState() *CycleState
NewCycleState initializes a new CycleState and returns its pointer.
func (*CycleState) Clone ¶
func (c *CycleState) Clone() fwk.CycleState
Clone creates a copy of CycleState and returns its pointer. Clone returns nil if the context being cloned is nil.
func (*CycleState) Delete ¶
func (c *CycleState) Delete(key fwk.StateKey)
Delete deletes data with the given key from CycleState.
See CycleState for notes on concurrency.
func (*CycleState) GetSkipFilterPlugins ¶ added in v1.34.0
func (c *CycleState) GetSkipFilterPlugins() sets.Set[string]
func (*CycleState) GetSkipPreBindPlugins ¶ added in v1.34.0
func (c *CycleState) GetSkipPreBindPlugins() sets.Set[string]
func (*CycleState) GetSkipScorePlugins ¶ added in v1.34.0
func (c *CycleState) GetSkipScorePlugins() sets.Set[string]
func (*CycleState) Read ¶
Read retrieves data with the given "key" from CycleState. If the key is not present, ErrNotFound is returned.
See CycleState for notes on concurrency.
func (*CycleState) SetRecordPluginMetrics ¶
func (c *CycleState) SetRecordPluginMetrics(flag bool)
SetRecordPluginMetrics sets recordPluginMetrics to the given value.
func (*CycleState) SetSkipFilterPlugins ¶ added in v1.34.0
func (c *CycleState) SetSkipFilterPlugins(plugins sets.Set[string])
func (*CycleState) SetSkipPreBindPlugins ¶ added in v1.34.0
func (c *CycleState) SetSkipPreBindPlugins(plugins sets.Set[string])
func (*CycleState) SetSkipScorePlugins ¶ added in v1.34.0
func (c *CycleState) SetSkipScorePlugins(plugins sets.Set[string])
func (*CycleState) ShouldRecordPluginMetrics ¶
func (c *CycleState) ShouldRecordPluginMetrics() bool
ShouldRecordPluginMetrics returns whether metrics.PluginExecutionDuration metrics should be recorded.
type Diagnosis ¶ added in v1.21.0
type Diagnosis struct {
// NodeToStatus records the status of nodes and generic status for absent ones.
// if they're rejected in PreFilter (via PreFilterResult) or Filter plugins.
// Nodes that pass PreFilter/Filter plugins are not included in this map.
NodeToStatus *NodeToStatus
// UnschedulablePlugins are plugins that returns Unschedulable or UnschedulableAndUnresolvable.
UnschedulablePlugins sets.Set[string]
// UnschedulablePlugins are plugins that returns Pending.
PendingPlugins sets.Set[string]
// PreFilterMsg records the messages returned from PreFilter plugins.
PreFilterMsg string
// PostFilterMsg records the messages returned from PostFilter plugins.
PostFilterMsg string
}
Diagnosis records the details to diagnose a scheduling failure.
func (*Diagnosis) AddPluginStatus ¶ added in v1.29.0
type Framework ¶
type Framework interface {
fwk.Handle
// PreEnqueuePlugins returns the registered preEnqueue plugins.
PreEnqueuePlugins() []fwk.PreEnqueuePlugin
// EnqueueExtensions returns the registered Enqueue extensions.
EnqueueExtensions() []fwk.EnqueueExtensions
// QueueSortFunc returns the function to sort pods in scheduling queue
QueueSortFunc() fwk.LessFunc
// RunPreFilterPlugins runs the set of configured PreFilter plugins. It returns
// *fwk.Status and its code is set to non-success if any of the plugins returns
// anything but Success. If a non-success status is returned, then the scheduling
// cycle is aborted.
// It also returns a PreFilterResult, which may influence what or how many nodes to
// evaluate downstream.
// The third returns value contains PreFilter plugin that rejected some or all Nodes with PreFilterResult.
// But, note that it doesn't contain any plugin when a plugin rejects this Pod with non-success status,
// not with PreFilterResult.
RunPreFilterPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod) (*fwk.PreFilterResult, *fwk.Status, sets.Set[string])
// RunPostFilterPlugins runs the set of configured PostFilter plugins.
// PostFilter plugins can either be informational, in which case should be configured
// to execute first and return Unschedulable status, or ones that try to change the
// cluster state to make the pod potentially schedulable in a future scheduling cycle.
RunPostFilterPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, filteredNodeStatusMap fwk.NodeToStatusReader) (*fwk.PostFilterResult, *fwk.Status)
// RunPreBindPlugins runs the set of configured PreBind plugins. It returns
// *fwk.Status and its code is set to non-success if any of the plugins returns
// anything but Success. If the Status code is "Unschedulable", it is
// considered as a scheduling check failure, otherwise, it is considered as an
// internal error. In either case the pod is not going to be bound.
RunPreBindPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status
// RunPreBindPreFlights runs the set of configured PreBindPreFlight functions from PreBind plugins.
// It returns immediately if any of the plugins returns a non-skip status.
RunPreBindPreFlights(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status
// RunPostBindPlugins runs the set of configured PostBind plugins.
RunPostBindPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string)
// RunReservePluginsReserve runs the Reserve method of the set of
// configured Reserve plugins. If any of these calls returns an error, it
// does not continue running the remaining ones and returns the error. In
// such case, pod will not be scheduled.
RunReservePluginsReserve(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status
// RunReservePluginsUnreserve runs the Unreserve method of the set of
// configured Reserve plugins.
RunReservePluginsUnreserve(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string)
// RunPermitPlugins runs the set of configured Permit plugins. If any of these
// plugins returns a status other than "Success" or "Wait", it does not continue
// running the remaining plugins and returns an error. Otherwise, if any of the
// plugins returns "Wait", then this function will create and add waiting pod
// to a map of currently waiting pods and return status with "Wait" code.
// Pod will remain waiting pod for the minimum duration returned by the Permit plugins.
RunPermitPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status
// WillWaitOnPermit returns whether this pod will wait on permit by checking if the pod is a waiting pod.
WillWaitOnPermit(ctx context.Context, pod *v1.Pod) bool
// WaitOnPermit will block, if the pod is a waiting pod, until the waiting pod is rejected or allowed.
WaitOnPermit(ctx context.Context, pod *v1.Pod) *fwk.Status
// RunBindPlugins runs the set of configured Bind plugins. A Bind plugin may choose
// whether or not to handle the given Pod. If a Bind plugin chooses to skip the
// binding, it should return code=5("skip") status. Otherwise, it should return "Error"
// or "Success". If none of the plugins handled binding, RunBindPlugins returns
// code=5("skip") status.
RunBindPlugins(ctx context.Context, state fwk.CycleState, pod *v1.Pod, nodeName string) *fwk.Status
// HasFilterPlugins returns true if at least one Filter plugin is defined.
HasFilterPlugins() bool
// HasPostFilterPlugins returns true if at least one PostFilter plugin is defined.
HasPostFilterPlugins() bool
// HasScorePlugins returns true if at least one Score plugin is defined.
HasScorePlugins() bool
// ListPlugins returns a map of extension point name to list of configured Plugins.
ListPlugins() *config.Plugins
// ProfileName returns the profile name associated to a profile.
ProfileName() string
// PercentageOfNodesToScore returns percentageOfNodesToScore associated to a profile.
PercentageOfNodesToScore() *int32
// SetPodNominator sets the PodNominator
SetPodNominator(nominator fwk.PodNominator)
// SetPodActivator sets the PodActivator
SetPodActivator(activator fwk.PodActivator)
// SetAPICacher sets the APICacher
SetAPICacher(apiCacher fwk.APICacher)
// Close calls Close method of each plugin.
Close() error
}
Framework manages the set of plugins in use by the scheduling framework. Configured plugins are called at specified points in a scheduling context.
type NodeInfo ¶
type NodeInfo struct {
// Pods running on the node.
Pods []fwk.PodInfo
// The subset of pods with affinity.
PodsWithAffinity []fwk.PodInfo
// The subset of pods with required anti-affinity.
PodsWithRequiredAntiAffinity []fwk.PodInfo
// Ports allocated on the node.
UsedPorts fwk.HostPortInfo
// Total requested resources of all pods on this node. This includes assumed
// pods, which scheduler has sent for binding, but may not be scheduled yet.
Requested *Resource
// Total requested resources of all pods on this node with a minimum value
// applied to each container's CPU and memory requests. This does not reflect
// the actual resource requests for this node, but is used to avoid scheduling
// many zero-request pods onto one node.
NonZeroRequested *Resource
// We store allocatedResources (which is Node.Status.Allocatable.*) explicitly
// as int64, to avoid conversions and accessing map.
Allocatable *Resource
// ImageStates holds the entry of an image if and only if this image is on the node. The entry can be used for
// checking an image's existence and advanced usage (e.g., image locality scheduling policy) based on the image
// state information.
ImageStates map[string]*fwk.ImageStateSummary
// PVCRefCounts contains a mapping of PVC names to the number of pods on the node using it.
// Keys are in the format "namespace/name".
PVCRefCounts map[string]int
// Whenever NodeInfo changes, generation is bumped.
// This is used to avoid cloning it if the object didn't change.
Generation int64
// 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) AddPodInfo ¶ added in v1.21.0
AddPodInfo adds pod information to this NodeInfo. Consider using this instead of AddPod if a PodInfo is already computed.
func (*NodeInfo) GetAllocatable ¶ added in v1.34.0
func (*NodeInfo) GetGeneration ¶ added in v1.34.0
func (*NodeInfo) GetImageStates ¶ added in v1.34.0
func (n *NodeInfo) GetImageStates() map[string]*fwk.ImageStateSummary
func (*NodeInfo) GetName ¶ added in v1.31.0
GetName returns the name of the node wrapped by this NodeInfo object, or a meaningful nil representation if node or node name is nil. This method is a part of interface KMetadata.
func (*NodeInfo) GetNamespace ¶ added in v1.31.0
GetNamespace is a part of interface KMetadata. For NodeInfo it should always return an empty string, since Node is not a namespaced resource.
func (*NodeInfo) GetNonZeroRequested ¶ added in v1.34.0
func (*NodeInfo) GetPVCRefCounts ¶ added in v1.34.0
func (*NodeInfo) GetPodsWithAffinity ¶ added in v1.34.0
func (*NodeInfo) GetPodsWithRequiredAntiAffinity ¶ added in v1.34.0
func (*NodeInfo) GetRequested ¶ added in v1.34.0
func (*NodeInfo) GetUsedPorts ¶ added in v1.34.0
func (n *NodeInfo) GetUsedPorts() fwk.HostPortInfo
func (*NodeInfo) RemoveNode ¶
func (n *NodeInfo) RemoveNode()
RemoveNode removes the node object, leaving all other tracking information.
func (*NodeInfo) Snapshot ¶ added in v1.29.0
Snapshot returns a copy of this node, same as SnapshotConcrete, but with returned type fwk.NodeInfo (the purpose is to have NodeInfo implement interface fwk.NodeInfo).
func (*NodeInfo) SnapshotConcrete ¶ added in v1.34.0
SnapshotConcrete returns a copy of this node, Except that ImageStates is copied without the Nodes field.
type NodeToStatus ¶ added in v1.32.0
type NodeToStatus struct {
// contains filtered or unexported fields
}
NodeToStatus contains the statuses of the Nodes where the incoming Pod was not schedulable.
func NewDefaultNodeToStatus ¶ added in v1.32.0
func NewDefaultNodeToStatus() *NodeToStatus
NewDefaultNodeToStatus creates NodeToStatus without any node in the map. The absentNodesStatus is set by default to UnschedulableAndUnresolvable.
func NewNodeToStatus ¶ added in v1.32.0
func NewNodeToStatus(nodeToStatus map[string]*fwk.Status, absentNodesStatus *fwk.Status) *NodeToStatus
NewNodeToStatus creates NodeToStatus initialized with given nodeToStatus and absentNodesStatus.
func (*NodeToStatus) AbsentNodesStatus ¶ added in v1.32.0
func (m *NodeToStatus) AbsentNodesStatus() *fwk.Status
AbsentNodesStatus returns absentNodesStatus value.
func (*NodeToStatus) ForEachExplicitNode ¶ added in v1.32.0
func (m *NodeToStatus) ForEachExplicitNode(fn func(nodeName string, status *fwk.Status))
ForEachExplicitNode runs fn for each node which status is explicitly set. Imporatant note, it runs the fn only for nodes with a status explicitly registered, and hence may not run the fn for all existing nodes. For example, if PreFilter rejects all Nodes, the scheduler would NOT set a failure status to every Node, but set a failure status as AbsentNodesStatus. You're supposed to get a status from AbsentNodesStatus(), and consider all other nodes that are rejected by them.
func (*NodeToStatus) Get ¶ added in v1.32.0
func (m *NodeToStatus) Get(nodeName string) *fwk.Status
Get returns the status for given nodeName. If the node is not in the map, the absentNodesStatus is returned.
func (*NodeToStatus) Len ¶ added in v1.32.0
func (m *NodeToStatus) Len() int
Len returns length of nodeToStatus map. It is not aware of number of absent nodes.
func (*NodeToStatus) NodesForStatusCode ¶ added in v1.32.0
func (m *NodeToStatus) NodesForStatusCode(nodeLister fwk.NodeInfoLister, code fwk.Code) ([]fwk.NodeInfo, error)
NodesForStatusCode returns a list of NodeInfos for the nodes that matches a given status code. If the absentNodesStatus matches the code, all existing nodes are fetched using nodeLister and filtered using NodeToStatus.Get. If the absentNodesStatus doesn't match the code, nodeToStatus map is used to create a list of nodes and nodeLister.Get is used to obtain NodeInfo for each.
func (*NodeToStatus) Set ¶ added in v1.32.0
func (m *NodeToStatus) Set(nodeName string, status *fwk.Status)
Set sets status for given nodeName.
func (*NodeToStatus) SetAbsentNodesStatus ¶ added in v1.32.0
func (m *NodeToStatus) SetAbsentNodesStatus(status *fwk.Status)
SetAbsentNodesStatus sets absentNodesStatus value.
type PodInfo ¶
type PodInfo struct {
Pod *v1.Pod
RequiredAffinityTerms []fwk.AffinityTerm
RequiredAntiAffinityTerms []fwk.AffinityTerm
PreferredAffinityTerms []fwk.WeightedAffinityTerm
PreferredAntiAffinityTerms []fwk.WeightedAffinityTerm
// contains filtered or unexported fields
}
PodInfo is a wrapper to a Pod with additional pre-computed information to accelerate processing. This information is typically immutable (e.g., pre-processed inter-pod affinity selectors).
func (*PodInfo) CalculateResource ¶ added in v1.34.0
func (pi *PodInfo) CalculateResource() fwk.PodResource
func (*PodInfo) GetPreferredAffinityTerms ¶ added in v1.34.0
func (pi *PodInfo) GetPreferredAffinityTerms() []fwk.WeightedAffinityTerm
func (*PodInfo) GetPreferredAntiAffinityTerms ¶ added in v1.34.0
func (pi *PodInfo) GetPreferredAntiAffinityTerms() []fwk.WeightedAffinityTerm
func (*PodInfo) GetRequiredAffinityTerms ¶ added in v1.34.0
func (pi *PodInfo) GetRequiredAffinityTerms() []fwk.AffinityTerm
func (*PodInfo) GetRequiredAntiAffinityTerms ¶ added in v1.34.0
func (pi *PodInfo) GetRequiredAntiAffinityTerms() []fwk.AffinityTerm
type PodsToActivate ¶ added in v1.22.0
type PodsToActivate struct {
sync.Mutex
// Map is keyed with namespaced pod name, and valued with the pod.
Map map[string]*v1.Pod
}
PodsToActivate stores pods to be activated.
func NewPodsToActivate ¶ added in v1.22.0
func NewPodsToActivate() *PodsToActivate
NewPodsToActivate instantiates a PodsToActivate object.
func (*PodsToActivate) Clone ¶ added in v1.22.0
func (s *PodsToActivate) Clone() fwk.StateData
Clone just returns the same state.
type QueuedPodInfo ¶
type QueuedPodInfo struct {
*PodInfo
// The time pod added to the scheduling queue.
Timestamp time.Time
// Number of all schedule attempts before successfully scheduled.
// It's used to record the # attempts metric.
Attempts int
// BackoffExpiration is the time when the Pod will complete its backoff.
// If the SchedulerPopFromBackoffQ feature is enabled, the value is aligned to the backoff ordering window.
// Then, two Pods with the same BackoffExpiration (time bucket) are ordered by priority and eventually the timestamp,
// to make sure popping from the backoffQ considers priority of pods that are close to the expiration time.
BackoffExpiration time.Time
// The total number of the scheduling attempts that this Pod gets unschedulable.
// Basically it equals Attempts, but when the Pod fails with the Error status (e.g., the network error),
// this count won't be incremented.
// It's used to calculate the backoff time this Pod is obliged to get before retrying.
UnschedulableCount int
// The number of the error status that this Pod gets sequentially.
// This count is reset when the Pod gets another status than Error.
//
// If the error status is returned (e.g., kube-apiserver is unstable), we don't want to immediately retry the Pod and hence need a backoff retry mechanism
// because that might push more burden to the kube-apiserver.
// But, we don't want to calculate the backoff time in the same way as the normal unschedulable reason
// since the purpose is different; the backoff for a unschedulable status etc is for the punishment of wasting the scheduling cycles,
// whereas the backoff for the error status is for the protection of the kube-apiserver.
// That's why we need to distinguish ConsecutiveErrorsCount for the error status and UnschedulableCount for the unschedulable status.
// See https://github.com/kubernetes/kubernetes/issues/128744 for the discussion.
ConsecutiveErrorsCount int
// The time when the pod is added to the queue for the first time. The pod may be added
// back to the queue multiple times before it's successfully scheduled.
// It shouldn't be updated once initialized. It's used to record the e2e scheduling
// latency for a pod.
InitialAttemptTimestamp *time.Time
// UnschedulablePlugins records the plugin names that the Pod failed with Unschedulable or UnschedulableAndUnresolvable status
// at specific extension points: PreFilter, Filter, Reserve, or Permit (WaitOnPermit).
// If Pods are rejected at other extension points,
// they're assumed to be unexpected errors (e.g., temporal network issue, plugin implementation issue, etc)
// and retried soon after a backoff period.
// That is because such failures could be solved regardless of incoming cluster events (registered in EventsToRegister).
UnschedulablePlugins sets.Set[string]
// PendingPlugins records the plugin names that the Pod failed with Pending status.
PendingPlugins sets.Set[string]
// GatingPlugin records the plugin name that gated the Pod at PreEnqueue.
GatingPlugin string
// GatingPluginEvents records the events registered by the plugin that gated the Pod at PreEnqueue.
// We have it as a cache purpose to avoid re-computing which event(s) might ungate the Pod.
GatingPluginEvents []fwk.ClusterEvent
}
QueuedPodInfo is a Pod wrapper with additional information related to the pod's status in the scheduling queue, such as the timestamp when it's added to the queue.
func (*QueuedPodInfo) DeepCopy ¶
func (pqi *QueuedPodInfo) DeepCopy() *QueuedPodInfo
DeepCopy returns a deep copy of the QueuedPodInfo object.
func (*QueuedPodInfo) Gated ¶ added in v1.26.0
func (pqi *QueuedPodInfo) Gated() bool
Gated returns true if the pod is gated by any plugin.
func (*QueuedPodInfo) GetAttempts ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetAttempts() int
func (*QueuedPodInfo) GetBackoffExpiration ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetBackoffExpiration() time.Time
func (*QueuedPodInfo) GetConsecutiveErrorsCount ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetConsecutiveErrorsCount() int
func (*QueuedPodInfo) GetGatingPlugin ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetGatingPlugin() string
func (*QueuedPodInfo) GetGatingPluginEvents ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetGatingPluginEvents() []fwk.ClusterEvent
func (*QueuedPodInfo) GetInitialAttemptTimestamp ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetInitialAttemptTimestamp() *time.Time
func (*QueuedPodInfo) GetPendingPlugins ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetPendingPlugins() sets.Set[string]
func (*QueuedPodInfo) GetPodInfo ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetPodInfo() fwk.PodInfo
func (*QueuedPodInfo) GetTimestamp ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetTimestamp() time.Time
func (*QueuedPodInfo) GetUnschedulableCount ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetUnschedulableCount() int
func (*QueuedPodInfo) GetUnschedulablePlugins ¶ added in v1.34.0
func (pqi *QueuedPodInfo) GetUnschedulablePlugins() sets.Set[string]
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. Implementation is separate from interface fwk.Resource, because implementation of functions Add and SetMaxResource depends on internal scheduler util functions.
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) GetAllowedPodNumber ¶ added in v1.34.0
func (*Resource) GetEphemeralStorage ¶ added in v1.34.0
func (*Resource) GetMilliCPU ¶ added in v1.34.0
func (*Resource) GetScalarResources ¶ added in v1.34.0
func (r *Resource) GetScalarResources() map[v1.ResourceName]int64
func (*Resource) SetMaxResource ¶
func (r *Resource) SetMaxResource(rl v1.ResourceList)
SetMaxResource compares with ResourceList and takes max value for each Resource.