diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index fa7ffb8eab..ec5c1a1fc3 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -1504,6 +1504,7 @@ func sortKubeKinds(documentList [][]byte) ([][]byte, error) { return sortedDocumentList, nil } + func imageNamePrefix(imageName string) string { prefix := imageName s := strings.Split(prefix, ":") @@ -1663,7 +1664,10 @@ func (ic *ContainerEngine) PlayKubeDown(ctx context.Context, body io.Reader, opt } // Add the reports - reports.StopReport, err = ic.PodStop(ctx, podNames, entities.PodStopOptions{Ignore: true}) + reports.StopReport, err = ic.PodStop(ctx, podNames, entities.PodStopOptions{ + Ignore: true, + Timeout: -1, + }) if err != nil { return nil, err } diff --git a/test/e2e/play_kube_test.go b/test/e2e/play_kube_test.go index 31ee3e47ce..04d7e5d90c 100644 --- a/test/e2e/play_kube_test.go +++ b/test/e2e/play_kube_test.go @@ -273,8 +273,11 @@ spec: - name: testctr image: ` + CITEST_IMAGE + ` command: - - sleep - - inf + - /bin/sh + - -c + - | + trap exit SIGTERM + while :; do sleep 0.1; done volumeMounts: - mountPath: /var name: testing @@ -285,6 +288,30 @@ spec: claimName: testvol ` +var signalTest = ` +apiVersion: v1 +kind: Pod +metadata: + name: testpod +spec: + containers: + - name: testctr + image: ` + CITEST_IMAGE + ` + command: + - /bin/sh + - -c + - | + trap 'echo TERMINATED > /testvol/termfile; exit' SIGTERM + while true; do sleep 0.1; done + volumeMounts: + - mountPath: /testvol + name: testvol + volumes: + - name: testvol + persistentVolumeClaim: + claimName: testvol +` + var checkInfraImagePodYaml = ` apiVersion: v1 kind: Pod @@ -5569,6 +5596,28 @@ spec: Expect(checkVol.OutputToString()).To(Equal("testvol1")) }) + It("with graceful shutdown", func() { + + volumeCreate := podmanTest.Podman([]string{"volume", "create", "testvol"}) + volumeCreate.WaitWithDefaultTimeout() + Expect(volumeCreate).Should(ExitCleanly()) + + err = writeYaml(signalTest, kubeYaml) + Expect(err).ToNot(HaveOccurred()) + + playKube := podmanTest.Podman([]string{"kube", "play", kubeYaml}) + playKube.WaitWithDefaultTimeout() + Expect(playKube).Should(ExitCleanly()) + + teardown := podmanTest.Podman([]string{"kube", "down", kubeYaml}) + teardown.WaitWithDefaultTimeout() + Expect(teardown).Should(ExitCleanly()) + + session := podmanTest.Podman([]string{"run", "--volume", "testvol:/testvol", CITEST_IMAGE, "sh", "-c", "cat /testvol/termfile"}) + session.WaitWithDefaultTimeout() + Expect(session.OutputToString()).Should(ContainSubstring("TERMINATED")) + }) + It("with hostPath subpaths", func() { if !Containerized() { Skip("something is wrong with file permissions in CI or in the yaml creation. cannot ls or cat the fs unless in a container")