Skip to content

Commit 1abbb00

Browse files
committed
Double a couple of other timeouts
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent 9268313 commit 1abbb00

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

test/e2e/framework/job/wait.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,23 @@ type JobState func(job *batchv1.Job) string
4242
// WaitForJobPodsRunning wait for all pods for the Job named JobName in namespace ns to become Running. Only use
4343
// when pods will run for a long time, or it will be racy.
4444
func WaitForJobPodsRunning(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error {
45-
return waitForJobPodsInPhase(ctx, c, ns, jobName, expectedCount, v1.PodRunning)
45+
return waitForJobPodsInPhase(ctx, c, ns, jobName, expectedCount, v1.PodRunning, JobTimeout)
46+
}
47+
48+
// WaitForJobPodsRunningWithTimeout wait for all pods for the Job named JobName in namespace ns to become Running. Only use
49+
// when pods will run for a long time, or it will be racy. same as WaitForJobPodsRunning but with an additional timeout parameter
50+
func WaitForJobPodsRunningWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32, timeout time.Duration) error {
51+
return waitForJobPodsInPhase(ctx, c, ns, jobName, expectedCount, v1.PodRunning, timeout)
4652
}
4753

4854
// WaitForJobPodsSucceeded wait for all pods for the Job named JobName in namespace ns to become Succeeded.
4955
func WaitForJobPodsSucceeded(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32) error {
50-
return waitForJobPodsInPhase(ctx, c, ns, jobName, expectedCount, v1.PodSucceeded)
56+
return waitForJobPodsInPhase(ctx, c, ns, jobName, expectedCount, v1.PodSucceeded, JobTimeout)
5157
}
5258

5359
// waitForJobPodsInPhase wait for all pods for the Job named JobName in namespace ns to be in a given phase.
54-
func waitForJobPodsInPhase(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32, phase v1.PodPhase) error {
55-
return wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, false, func(ctx context.Context) (bool, error) {
60+
func waitForJobPodsInPhase(ctx context.Context, c clientset.Interface, ns, jobName string, expectedCount int32, phase v1.PodPhase, timeout time.Duration) error {
61+
return wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, false, func(ctx context.Context) (bool, error) {
5662
pods, err := GetJobPods(ctx, c, ns, jobName)
5763
if err != nil {
5864
return false, err
@@ -157,7 +163,12 @@ func isJobFailed(j *batchv1.Job) bool {
157163

158164
// WaitForJobFinish uses c to wait for the Job jobName in namespace ns to finish (either Failed or Complete).
159165
func WaitForJobFinish(ctx context.Context, c clientset.Interface, ns, jobName string) error {
160-
return wait.PollUntilContextTimeout(ctx, framework.Poll, JobTimeout, true, func(ctx context.Context) (bool, error) {
166+
return WaitForJobFinishWithTimeout(ctx, c, ns, jobName, JobTimeout)
167+
}
168+
169+
// WaitForJobFinishWithTimeout uses c to wait for the Job jobName in namespace ns to finish (either Failed or Complete).
170+
func WaitForJobFinishWithTimeout(ctx context.Context, c clientset.Interface, ns, jobName string, timeout time.Duration) error {
171+
return wait.PollUntilContextTimeout(ctx, framework.Poll, timeout, true, func(ctx context.Context) (bool, error) {
161172
curr, err := c.BatchV1().Jobs(ns).Get(ctx, jobName, metav1.GetOptions{})
162173
if err != nil {
163174
return false, err

test/e2e/node/gpu.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ var _ = SIGDescribe(feature.GPUDevicePlugin, framework.WithSerial(), "Test using
130130
framework.ExpectNoError(err)
131131

132132
// make sure job is running by waiting for its first pod to start running
133-
err = e2ejob.WaitForJobPodsRunning(ctx, f.ClientSet, f.Namespace.Name, job.Name, 1)
133+
err = e2ejob.WaitForJobPodsRunningWithTimeout(ctx, f.ClientSet, f.Namespace.Name, job.Name, 1, e2ejob.JobTimeout*2)
134134
framework.ExpectNoError(err)
135135

136136
numNodes, err := e2enode.TotalRegistered(ctx, f.ClientSet)
@@ -139,7 +139,7 @@ var _ = SIGDescribe(feature.GPUDevicePlugin, framework.WithSerial(), "Test using
139139
framework.ExpectNoError(err)
140140

141141
ginkgo.By("Waiting for gpu job to finish")
142-
err = e2ejob.WaitForJobFinish(ctx, f.ClientSet, f.Namespace.Name, job.Name)
142+
err = e2ejob.WaitForJobFinishWithTimeout(ctx, f.ClientSet, f.Namespace.Name, job.Name, e2ejob.JobTimeout*2)
143143
framework.ExpectNoError(err)
144144
ginkgo.By("Done with gpu job")
145145

0 commit comments

Comments
 (0)