Merge pull request #130166 from mimowo/automated-cherry-pick-of-#130164-upstream-release-1.31

Automated cherry pick of #130164: Deflake the PodReplacementPolicyFeatureToggling Job integration test
This commit is contained in:
Kubernetes Prow Robot 2025-02-25 11:58:29 -08:00 committed by GitHub
commit 00ba1de20b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3117,9 +3117,15 @@ func TestJobPodReplacementPolicyFeatureToggling(t *testing.T) {
Ready: ptr.To[int32](0),
Active: int(podCount),
})
// Disable the controller and turn feature on again.
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, true)
cancel()
// Disable the controller and turn feature on again.
// However, before we re-enabling the feature gate we wait a little (1s to
// wait for the syncJob re-queue after update + 100ms for the syncJob
// execution itself) to make sure there is no pending syncJob which could
// panic if the trackTerminating returned false at the start of the sync,
// but onlyReplaceFailedPods returned true during that sync.
time.Sleep(time.Second + sleepDurationForControllerLatency)
featuregatetesting.SetFeatureGateDuringTest(t, feature.DefaultFeatureGate, features.JobPodReplacementPolicy, true)
ctx, cancel = startJobControllerAndWaitForCaches(t, restConfig)
waitForPodsToBeActive(ctx, t, jobClient, 2, jobObj)
deletePods(ctx, t, clientSet, jobObj.Namespace)