Documentation ¶
Index ¶
- func AsBadRequestPanic()
- func BindPod(kClient kubeClient.Interface, bindingPod *core.Pod)
- func CreateClient(kConfig *rest.Config) kubeClient.Interface
- func ExtractPodBindAnnotations(allocatedPod *core.Pod) map[string]string
- func ExtractPodBindInfo(allocatedPod *core.Pod) *si.PodBindInfo
- func ExtractPodSchedulingSpec(pod *core.Pod) *si.PodSchedulingSpec
- func GetKey(obj interface{}) (string, error)
- func HandleInformerPanic(logPfx string, logOnSucceeded bool)
- func HandleRoutinePanic(logPfx string)
- func HandleWebServerPanic(handler func(*si.WebServerError))
- func IsAllocated(state PodState) bool
- func IsBound(pod *core.Pod) bool
- func IsCompleted(pod *core.Pod) bool
- func IsHivedEnabled(pod *core.Pod) bool
- func IsInterested(pod *core.Pod) bool
- func IsLive(pod *core.Pod) bool
- func IsNodeHealthy(node *core.Node) bool
- func IsUnbound(pod *core.Pod) bool
- func Key(p *core.Pod) string
- func NewBadRequestError(message string) *si.WebServerError
- func NewBindingPod(pod *core.Pod, podBindInfo *si.PodBindInfo) *core.Pod
- func SplitKey(key string) (namespace, name string, err error)
- func ToNode(obj interface{}) *core.Node
- func ToPod(obj interface{}) *core.Pod
- type ExtenderHandlers
- type InspectHandlers
- type PodKey
- type PodPreemptInfo
- type PodScheduleResult
- type PodScheduleStatus
- type PodScheduleStatuses
- type PodState
- type PodWaitInfo
- type SchedulerAlgorithm
- type SchedulingPhase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateClient ¶
func CreateClient(kConfig *rest.Config) kubeClient.Interface
func ExtractPodBindInfo ¶
func ExtractPodBindInfo(allocatedPod *core.Pod) *si.PodBindInfo
PodBindInfo comes from internal, so just need to assert when deserialization.
func ExtractPodSchedulingSpec ¶
func ExtractPodSchedulingSpec(pod *core.Pod) *si.PodSchedulingSpec
PodSchedulingSpec comes from external, so need more Defaulting and Validation when deserialization.
func HandleInformerPanic ¶
Recover User Error Panic Rethrow Platform Error Panic
func HandleWebServerPanic ¶
func HandleWebServerPanic(handler func(*si.WebServerError))
Log and Recover Panic
func IsAllocated ¶
func IsBound ¶
Scheduler only can see live Pod, so the IsLive() check is usually redundant. A bound Pod means it is currently holding its requested resources.
func IsCompleted ¶
func IsHivedEnabled ¶
func IsInterested ¶
Aligned with K8S HTTPExtender, so that Informer is also aligned with WebServer.
func IsNodeHealthy ¶ added in v0.3.0
A node is considered healthy if it is not unschedulable and in ready condition.
func NewBadRequestError ¶
func NewBadRequestError(message string) *si.WebServerError
func NewBindingPod ¶
Types ¶
type ExtenderHandlers ¶
type ExtenderHandlers struct { FilterHandler func(args ei.ExtenderArgs) *ei.ExtenderFilterResult BindHandler func(args ei.ExtenderBindingArgs) *ei.ExtenderBindingResult PreemptHandler func(args ei.ExtenderPreemptionArgs) *ei.ExtenderPreemptionResult }
WebServer Callbacks with K8S Default Scheduler Notes:
- Error should be delivered by panic
- Should not assume previous succeeded operation also has been successfully executed by K8S Default Scheduler.
type InspectHandlers ¶ added in v0.2.4
type InspectHandlers struct { GetAllAffinityGroupsHandler func() si.AffinityGroupList GetAffinityGroupHandler func(groupName string) si.AffinityGroup GetClusterStatusHandler func() si.ClusterStatus GetPhysicalClusterStatusHandler func() si.PhysicalClusterStatus GetAllVirtualClustersStatusHandler func() map[si.VirtualClusterName]si.VirtualClusterStatus GetVirtualClusterStatusHandler func(vcName si.VirtualClusterName) si.VirtualClusterStatus }
type PodPreemptInfo ¶
type PodPreemptInfo struct { // Only need to include the victim Pods for the current preemptor Pod. // Need to ensure the newly deleted victim Pods are eventually removed from here, // otherwise, the default scheduler refuse to execute any preemption. // Need to ensure the newly added victim Pods are eventually added to here, // otherwise, the preemption will never complete. // It can be empty, such as current preemptor Pod is waiting for the victim Pods // of other preemptor Pods in the same group to be preempted. // It can contain victim Pods across multiple nodes, such as a victim group may // contain Pods across multiple nodes. VictimPods []*core.Pod }
No need to use it recover scheduler preempting resource
type PodScheduleResult ¶
type PodScheduleResult struct { PodWaitInfo *PodWaitInfo PodPreemptInfo *PodPreemptInfo PodBindInfo *si.PodBindInfo }
Notes:
- If the SchedulerAlgorithm found sufficient free resource, only PodBindInfo should be set. If the SchedulerAlgorithm found sufficient preemptible resource, only PodPreemptInfo should be set. Otherwise, only PodWaitInfo can be optionally set.
- The selected node in PodBindInfo requires:
- Must be within candidateNodes: All existing nodes which can be constructed from AddNode/DeleteNode. Otherwise, the Pod after bound will be probably deleted by the GarbageCollectionController.
- Better to be within suggestedNodes: The input parameter of Schedule(). Otherwise, the Pod after bound will not respect previous pod schedule decision from K8S Default Scheduler, i.e. this binding is incompatible with K8S Default Scheduler.
type PodScheduleStatus ¶
type PodScheduleStatus struct { // The Pod which will be used in current PodState. // For example, in PodBinding state, it should be a Pod used to bind, // i.e. with all placements set in the Pod. Pod *core.Pod PodState PodState // The already tried Pod binding attempts, i.e. the scheduled times for a Pod // in PodBinding state. PodBindAttempts int32 PodScheduleResult *PodScheduleResult }
Used to track the PodScheduleResult
type PodScheduleStatuses ¶
type PodScheduleStatuses map[types.UID]*PodScheduleStatus
PodUID -> PodScheduleStatus
type PodState ¶
type PodState string
const ( // Pod is waiting for preemptible or free resource to appear. // [StartState] // -> PodPreempting // -> PodBinding PodWaiting PodState = "Waiting" // Pod is waiting for the appeared preemptible resource to be free by preemption. // -> PodBinding // -> PodWaiting PodPreempting PodState = "Preempting" // Pod is binding on the free resource. // [AllocatedState] // -> PodBound PodBinding PodState = "Binding" // Pod is bound on the free resource. // [FinalState] // [AllocatedState] PodBound PodState = "Bound" )
[AllocatedState]: The Pod is considered to be allocated from the scheduler view.
const PodUnknown PodState = "Unknown"
[VirtualState]: This state is not tracked in PodScheduleStatuses.
Pod is unknown for the scheduler, such as the Pod does not exist, completed or has not been informed to the scheduler.
A completed Pod is the same as a deleted Pod from the scheduler view and they will never be informed to the scheduler, thus they are rejected to be scheduled. However, the not yet informed not completed Pod will be eventually informed to the scheduler, then transition to not VirtualState, thus they are accepted to be scheduled.
This state can be transitioned from any state, but can only transition to: -> PodWaiting -> PodBound
type PodWaitInfo ¶
type PodWaitInfo struct { // The reason why no preemptible or free resource to allocate the Pod now. Reason string }
No need to use it recover scheduler waiting resource
type SchedulerAlgorithm ¶
type SchedulerAlgorithm interface { // See details in SchedulingPhase and PodScheduleResult. Schedule(pod *core.Pod, suggestedNodes []string, phase SchedulingPhase) PodScheduleResult // Track all current Nodes in the whole cluster. AddNode(node *core.Node) UpdateNode(oldNode, newNode *core.Node) DeleteNode(node *core.Node) // Track all current unallocated and allocated Pods in the whole cluster. // Unallocated Pod includes both PodWaiting and PodPreempting Pods. AddUnallocatedPod(pod *core.Pod) DeleteUnallocatedPod(pod *core.Pod) // Allocated Pod includes both PodBound and PodBinding Pods. AddAllocatedPod(pod *core.Pod) DeleteAllocatedPod(pod *core.Pod) // Expose current scheduling status GetAllAffinityGroups() si.AffinityGroupList GetAffinityGroup(name string) si.AffinityGroup GetClusterStatus() si.ClusterStatus GetPhysicalClusterStatus() si.PhysicalClusterStatus GetAllVirtualClustersStatus() map[si.VirtualClusterName]si.VirtualClusterStatus GetVirtualClusterStatus(si.VirtualClusterName) si.VirtualClusterStatus }
SchedulerAlgorithm is used to make the pod schedule decision based on its whole cluster scheduling view constructed from its Add/Update/Delete callbacks. Notes:
- Error should be delivered by panic and it will not change any state. For WebServer Callbacks, all Panics will be recovered as error responses, see HandleInformerPanic. For Informer Callbacks, only User Error Panics will be recovered as error logs, other Panics will crash the whole process, see HandleWebServerPanic.
- Should take all the input parameters as readonly and return pod schedule decision by PodScheduleResult.
- {Schedule, AddUnallocatedPod, DeleteUnallocatedPod, AddAllocatedPod, DeleteAllocatedPod} will never be executed concurrently for all pods.
- [Schedule -> (AddAllocatedPod) -> Schedule -> ...] is executed sequentially for all pods. I.e. the constructed scheduling view is already lock protected.
- [START -> AddAllocatedPod -> DeleteAllocatedPod -> END] is executed sequentially for one specific Pod. I.e. once a specific Pod is allocated by AddAllocatedPod, its placement will never be changed to another one.
type SchedulingPhase ¶ added in v0.3.1
type SchedulingPhase string
const ( // The Schedule is called during filterRoutine: // The suggestedNodes contain all nodes that can fit the pod without any // lower priority Pods preempted. FilteringPhase SchedulingPhase = "Filtering" // The Schedule is called during preemptRoutine: // The suggestedNodes contain all nodes that can fit the pod after all // lower priority Pods preempted. PreemptingPhase SchedulingPhase = "Preempting" )