in pkg/plugin/scheduler_plugin.go [90:138]
func (sp *YuniKornSchedulerPlugin) PreEnqueue(_ context.Context, pod *v1.Pod) *framework.Status {
log.Log(log.ShimSchedulerPlugin).Debug("PreEnqueue check",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name))
// we don't process pods without appID defined
appID := utils.GetApplicationIDFromPod(pod)
if appID == "" {
log.Log(log.ShimSchedulerPlugin).Debug("Releasing non-managed Pod for scheduling (PreEnqueue phase)",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name))
return nil
}
taskID := string(pod.UID)
if app, task, ok := sp.getTask(appID, taskID); ok {
if _, ok := sp.context.GetInProgressPodAllocation(taskID); ok {
// pod must have failed scheduling in a prior run, reject it and return unschedulable
sp.failTask(pod, app, task)
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod is not ready for scheduling")
}
nodeID, ok := sp.context.GetPendingPodAllocation(taskID)
if task.GetTaskState() == cache.TaskStates().Bound && ok {
log.Log(log.ShimSchedulerPlugin).Info("Releasing pod for scheduling (PreEnqueue phase)",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name),
zap.String("taskID", taskID),
zap.String("assignedNode", nodeID))
return nil
}
schedState := task.GetTaskSchedulingState()
switch schedState {
case cache.TaskSchedPending:
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod is pending scheduling")
case cache.TaskSchedFailed:
// allow the pod to proceed so that it will be marked unschedulable by PreFilter
return nil
case cache.TaskSchedSkipped:
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod doesn't fit within queue")
default:
return framework.NewStatus(framework.UnschedulableAndUnresolvable, fmt.Sprintf("Pod unschedulable: %s", schedState.String()))
}
}
// task not found (yet?) -- probably means cache update hasn't come through yet
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod not ready for scheduling")
}