in pkg/coscheduling/coscheduling.go [204:240]
func (cs *Coscheduling) Permit(ctx context.Context, state *framework.CycleState, pod *v1.Pod, nodeName string) (*framework.Status, time.Duration) {
fullName := util.GetPodGroupFullName(pod)
if len(fullName) == 0 {
return framework.NewStatus(framework.Success, ""), 0
}
waitTime := *cs.scheduleTimeout
ready, err := cs.pgMgr.Permit(ctx, pod, nodeName)
if err != nil {
_, pg := cs.pgMgr.GetPodGroup(pod)
if pg == nil {
return framework.NewStatus(framework.Unschedulable, "PodGroup not found"), 0
}
if wait := util.GetWaitTimeDuration(pg, cs.scheduleTimeout); wait != 0 {
waitTime = wait
}
if err == util.ErrorWaiting {
klog.Infof("Pod: %v is waiting to be scheduled to node: %v", core.GetNamespacedName(pod), nodeName)
return framework.NewStatus(framework.Wait, ""), waitTime
}
klog.Infof("Permit error %v", err)
return framework.NewStatus(framework.Unschedulable, err.Error()), 0
}
klog.V(5).Infof("Pod requires pgName %v", fullName)
if !ready {
return framework.NewStatus(framework.Wait, ""), waitTime
}
cs.frameworkHandler.IterateOverWaitingPods(func(waitingPod framework.WaitingPod) {
if util.GetPodGroupFullName(waitingPod.GetPod()) == fullName {
klog.V(3).Infof("Permit allows the pod: %v", core.GetNamespacedName(waitingPod.GetPod()))
waitingPod.Allow(cs.Name())
}
})
klog.V(3).Infof("Permit allows the pod: %v", core.GetNamespacedName(pod))
return framework.NewStatus(framework.Success, ""), 0
}