Commit ff9e57e5 authored by Darren Shepherd's avatar Darren Shepherd Committed by Erik Wilson

Alleviate race between scheduler and kubelet

If the scheduler learns of a node change and schedules based on it before the kubelet learns of the node change, the pod will fail.
parent 38acc2a5
......@@ -18,6 +18,7 @@ package lifecycle
import (
"fmt"
"time"
"k8s.io/klog"
......@@ -55,6 +56,19 @@ func NewPredicateAdmitHandler(getNodeAnyWayFunc getNodeAnyWayFuncType, admission
}
func (w *predicateAdmitHandler) Admit(attrs *PodAdmitAttributes) PodAdmitResult {
result := w.admit(attrs)
for i := 0; i < 10; i++ {
if result.Admit {
break
}
time.Sleep(time.Second)
result = w.admit(attrs)
}
return result
}
func (w *predicateAdmitHandler) admit(attrs *PodAdmitAttributes) PodAdmitResult {
node, err := w.getNodeAnyWayFunc()
if err != nil {
klog.Errorf("Cannot get Node info: %v", err)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment