Skip to content

Commit 2350e7a

Browse files
committed
deflake pod-resize-resource-quota-test
1 parent 34e80be commit 2350e7a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

test/e2e/node/pod_resize.go

+18-8
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,15 @@ func doPodResizeAdmissionPluginsTests() {
167167
e2epod.VerifyPodResources(resizedPod, expected)
168168

169169
ginkgo.By("patching pod for resize with memory exceeding resource quota")
170-
_, pErrExceedMemory := f.ClientSet.CoreV1().Pods(resizedPod.Namespace).Patch(ctx,
171-
resizedPod.Name, types.StrategicMergePatchType, []byte(patchStringExceedMemory), metav1.PatchOptions{}, "resize")
172-
gomega.Expect(pErrExceedMemory).To(gomega.HaveOccurred())
173-
gomega.Expect(pErrExceedMemory).To(gomega.MatchError(gomega.ContainSubstring(tc.wantMemoryError)))
170+
framework.ExpectNoError(framework.Gomega().
171+
// Use Eventually because we need to wait for the quota controller to sync.
172+
Eventually(ctx, func(ctx context.Context) error {
173+
_, pErrExceedMemory := f.ClientSet.CoreV1().Pods(resizedPod.Namespace).Patch(ctx,
174+
resizedPod.Name, types.StrategicMergePatchType, []byte(patchStringExceedMemory), metav1.PatchOptions{DryRun: []string{metav1.DryRunAll}}, "resize")
175+
return pErrExceedMemory
176+
}).
177+
WithTimeout(f.Timeouts.PodStart).
178+
Should(gomega.MatchError(gomega.ContainSubstring(tc.wantMemoryError))))
174179

175180
ginkgo.By("verifying pod patched for resize exceeding memory resource quota remains unchanged")
176181
patchedPodExceedMemory, pErrEx2 := podClient.Get(ctx, resizedPod.Name, metav1.GetOptions{})
@@ -179,10 +184,15 @@ func doPodResizeAdmissionPluginsTests() {
179184
framework.ExpectNoError(e2epod.VerifyPodStatusResources(patchedPodExceedMemory, expected))
180185

181186
ginkgo.By(fmt.Sprintf("patching pod %s for resize with CPU exceeding resource quota", resizedPod.Name))
182-
_, pErrExceedCPU := f.ClientSet.CoreV1().Pods(resizedPod.Namespace).Patch(ctx,
183-
resizedPod.Name, types.StrategicMergePatchType, []byte(patchStringExceedCPU), metav1.PatchOptions{}, "resize")
184-
gomega.Expect(pErrExceedCPU).To(gomega.HaveOccurred())
185-
gomega.Expect(pErrExceedCPU).To(gomega.MatchError(gomega.ContainSubstring(tc.wantCPUError)))
187+
framework.ExpectNoError(framework.Gomega().
188+
// Use Eventually because we need to wait for the quota controller to sync.
189+
Eventually(ctx, func(ctx context.Context) error {
190+
_, pErrExceedCPU := f.ClientSet.CoreV1().Pods(resizedPod.Namespace).Patch(ctx,
191+
resizedPod.Name, types.StrategicMergePatchType, []byte(patchStringExceedCPU), metav1.PatchOptions{DryRun: []string{metav1.DryRunAll}}, "resize")
192+
return pErrExceedCPU
193+
}).
194+
WithTimeout(f.Timeouts.PodStart).
195+
Should(gomega.MatchError(gomega.ContainSubstring(tc.wantCPUError))))
186196

187197
ginkgo.By("verifying pod patched for resize exceeding CPU resource quota remains unchanged")
188198
patchedPodExceedCPU, pErrEx1 := podClient.Get(ctx, resizedPod.Name, metav1.GetOptions{})

0 commit comments

Comments
 (0)