Skip to content

Commit a0f0e58

Browse files
committed
kubectl run test wait until pod terminates
the test "executing a command with run and attach without stdin" is inherently flaky, there are several discussion but seems that it requires changing the way the kubectl run and attach works. The test fails if we are not able to attach before the container prints "stdin closed", but hasn't exited yet. Because the race seems difficult to solve, we can wait 5 seconds before printing to give time to kubectl to attach to the container.
1 parent 2b00dd8 commit a0f0e58

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/e2e/kubectl/kubectl.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,12 @@ var _ = SIGDescribe("Kubectl client", func() {
561561
gomega.Expect(c.CoreV1().Pods(ns).Delete(context.TODO(), "run-test", metav1.DeleteOptions{})).To(gomega.BeNil())
562562

563563
ginkgo.By("executing a command with run and attach without stdin")
564-
runOutput = framework.NewKubectlCommand(ns, fmt.Sprintf("--namespace=%v", ns), "run", "run-test-2", "--image="+busyboxImage, "--restart=OnFailure", "--attach=true", "--leave-stdin-open=true", "--", "sh", "-c", "cat && echo 'stdin closed'").
564+
// There is a race on this scenario described in #73099
565+
// It fails if we are not able to attach before the container prints
566+
// "stdin closed", but hasn't exited yet.
567+
// We wait 5 seconds before printing to give time to kubectl to attach
568+
// to the container, this does not solve the race though.
569+
runOutput = framework.NewKubectlCommand(ns, fmt.Sprintf("--namespace=%v", ns), "run", "run-test-2", "--image="+busyboxImage, "--restart=OnFailure", "--attach=true", "--leave-stdin-open=true", "--", "sh", "-c", "sleep 5; cat && echo 'stdin closed'").
565570
WithStdinData("abcd1234").
566571
ExecOrDie(ns)
567572
gomega.Expect(runOutput).ToNot(gomega.ContainSubstring("abcd1234"))

0 commit comments

Comments
 (0)