in pkg/plugin/scheduler_plugin.go [184:218]
func (sp *YuniKornSchedulerPlugin) Filter(_ context.Context, _ *framework.CycleState, pod *v1.Pod, nodeInfo *framework.NodeInfo) *framework.Status {
log.Log(log.ShimSchedulerPlugin).Debug("Filter check",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name),
zap.String("node", nodeInfo.Node().Name))
// we don't process pods without appID defined
appID := utils.GetApplicationIDFromPod(pod)
if appID == "" {
log.Log(log.ShimSchedulerPlugin).Debug("Releasing non-managed Pod fo scheduling (Filter phase)",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name))
return nil
}
taskID := string(pod.UID)
if _, task, ok := sp.getTask(appID, taskID); ok {
if task.GetTaskState() == cache.TaskStates().Bound {
// attempt to start a pod allocation. Filter() gets called once per {Pod,Node} candidate; we only want
// to proceed in the case where the Node we are asked about matches the one YuniKorn has selected.
// this check is fairly cheap (one map lookup); if we fail the check here the scheduling framework will
// immediately call Filter() again with a different candidate Node.
if sp.context.StartPodAllocation(taskID, nodeInfo.Node().Name) {
log.Log(log.ShimSchedulerPlugin).Info("Releasing pod for scheduling (Filter phase)",
zap.String("namespace", pod.Namespace),
zap.String("pod", pod.Name),
zap.String("taskID", taskID),
zap.String("assignedNode", nodeInfo.Node().Name))
return nil
}
}
}
return framework.NewStatus(framework.UnschedulableAndUnresolvable, "Pod is not fit for node")
}