Skip to content

Commit 6fb2548

Browse files
committed
add retry for update operation
Signed-off-by: Weiyu Yen <[email protected]>
1 parent b72ad04 commit 6fb2548

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/controller.v1/pytorch/pytorchjob_controller_test.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -203,14 +203,19 @@ var _ = Describe("PyTorchJob controller", func() {
203203

204204
By("Attempting to update the PyTorchJob with a different queue value")
205205
updatedJob := &kubeflowv1.PyTorchJob{}
206-
Expect(testK8sClient.Get(ctx, client.ObjectKeyFromObject(job), updatedJob)).Should(Succeed(), "Failed to get PyTorchJob")
207-
208-
updatedJob.Spec.RunPolicy.SchedulingPolicy.Queue = "test"
209-
err := testK8sClient.Update(ctx, updatedJob)
206+
Eventually(func() bool {
207+
err := testK8sClient.Get(ctx, jobKey, updatedJob)
208+
return err == nil
209+
}, testutil.Timeout, testutil.Interval).Should(BeTrue(), "Failed to get PyTorchJob")
210210

211-
By("Checking that the queue update fails")
212-
Expect(err).To(HaveOccurred(), "Expected an error when updating the queue, but update succeeded")
213-
Expect(err.Error()).To(ContainSubstring("spec.runPolicy.schedulingPolicy.queue is immutable"), "The error message did not contain the expected message")
211+
Eventually(func() bool {
212+
updatedJob.Spec.RunPolicy.SchedulingPolicy.Queue = "test"
213+
err := testK8sClient.Update(ctx, updatedJob)
214+
By("Checking that the queue update fails")
215+
Expect(err).To(HaveOccurred(), "Expected an error when updating the queue, but update succeeded")
216+
Expect(err).To(MatchError(ContainSubstring("spec.runPolicy.schedulingPolicy.queue is immutable"), "The error message did not contain the expected message"))
217+
return err != nil
218+
}, testutil.Timeout, testutil.Interval).Should(BeTrue())
214219

215220
By("Validating the queue was not updated")
216221
freshJob := &kubeflowv1.PyTorchJob{}

0 commit comments

Comments
 (0)