Skip to content

Commit c4434c3

Browse files
authored
Merge pull request kubernetes#129910 from bitoku/fix-129836
Fix flaky test for container life cycle
2 parents fab0d76 + da5a76b commit c4434c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

test/e2e_node/container_lifecycle_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun
880880
gomega.Expect(err).To(gomega.HaveOccurred())
881881
})
882882

883-
f.It("should continue running liveness probes for restartable init containers and restart them while in preStop", f.WithNodeConformance(), func(ctx context.Context) {
883+
f.It("should not continue running liveness probes for restartable init containers and restart them while in preStop", f.WithNodeConformance(), func(ctx context.Context) {
884884
client := e2epod.NewPodClient(f)
885885
podSpec := testPod()
886886
restartableInit1 := "restartable-init-1"
@@ -913,6 +913,8 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun
913913
PreStop: &v1.LifecycleHandler{
914914
Exec: &v1.ExecAction{
915915
Command: ExecCommand(prefixedName(PreStopPrefix, regular1), execCommand{
916+
// Delay 10 secs not to make a race condition.
917+
StartDelay: 10,
916918
Delay: 40,
917919
ExitCode: 0,
918920
ContainerName: regular1,
@@ -937,8 +939,9 @@ var _ = SIGDescribe(framework.WithNodeConformance(), "Containers Lifecycle", fun
937939
ginkgo.By("Analyzing results")
938940
// FIXME ExpectNoError: this will be implemented in KEP 4438
939941
// liveness probes are called for restartable init containers during pod termination
940-
err = results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, restartableInit1))
941-
gomega.Expect(err).To(gomega.HaveOccurred())
942+
err = results.StartsBefore(prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, restartableInit1))
943+
gomega.Expect(err).To(gomega.HaveOccurred(),
944+
"%s should not start before %s", prefixedName(PreStopPrefix, regular1), prefixedName(LivenessPrefix, restartableInit1))
942945
// FIXME ExpectNoError: this will be implemented in KEP 4438
943946
// restartable init containers are restarted during pod termination
944947
err = results.RunTogetherLhsFirst(prefixedName(PreStopPrefix, regular1), restartableInit1)

0 commit comments

Comments
 (0)