Commit 55814978 authored by Bobby (Babak) Salamat's avatar Bobby (Babak) Salamat

Add a test that reproduces the race condition between setting nominated node…

Add a test that reproduces the race condition between setting nominated node name of a pod and scheduling cycle of other pods
parent aee1ab34
...@@ -584,6 +584,17 @@ func podScheduled(c clientset.Interface, podNamespace, podName string) wait.Cond ...@@ -584,6 +584,17 @@ func podScheduled(c clientset.Interface, podNamespace, podName string) wait.Cond
// podUnschedulable returns a condition function that returns true if the given pod // podUnschedulable returns a condition function that returns true if the given pod
// gets unschedulable status. // gets unschedulable status.
func podSchedulableCondition(c clientset.Interface, podNamespace, podName string) (*v1.PodCondition, error) {
pod, err := c.CoreV1().Pods(podNamespace).Get(podName, metav1.GetOptions{})
if err != nil {
return nil, err
}
_, cond := podutil.GetPodCondition(&pod.Status, v1.PodScheduled)
return cond, nil
}
// podUnschedulable returns a condition function that returns true if the given pod
// gets unschedulable status.
func podUnschedulable(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc { func podUnschedulable(c clientset.Interface, podNamespace, podName string) wait.ConditionFunc {
return func() (bool, error) { return func() (bool, error) {
pod, err := c.CoreV1().Pods(podNamespace).Get(podName, metav1.GetOptions{}) pod, err := c.CoreV1().Pods(podNamespace).Get(podName, metav1.GetOptions{})
...@@ -710,7 +721,7 @@ func cleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod) { ...@@ -710,7 +721,7 @@ func cleanupPods(cs clientset.Interface, t *testing.T, pods []*v1.Pod) {
} }
} }
for _, p := range pods { for _, p := range pods {
if err := wait.Poll(time.Second, wait.ForeverTestTimeout, if err := wait.Poll(time.Millisecond, wait.ForeverTestTimeout,
podDeleted(cs, p.Namespace, p.Name)); err != nil { podDeleted(cs, p.Namespace, p.Name)); err != nil {
t.Errorf("error while waiting for pod %v/%v to get deleted: %v", p.Namespace, p.Name, err) t.Errorf("error while waiting for pod %v/%v to get deleted: %v", p.Namespace, p.Name, 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