From 3e405a2fd140527eeeb817dfdfa802f8f59452d4 Mon Sep 17 00:00:00 2001 From: Urvashi Mohnani Date: Thu, 16 Mar 2023 11:28:50 -0400 Subject: [PATCH] Add service ctr cleanup to PlayKubeDown Since we can't guarantee when the worker queue will come and clean up the service container in the remote case when podman kube play --wait is called, cleanup the service container at the end of PlayKubeDown() to ensure that it is removed right after all the containers, pods, volumes, etc are removed. [NO NEW TESTS NEEDED] Signed-off-by: Urvashi Mohnani --- pkg/domain/infra/abi/play.go | 9 +++++++++ test/system/700-play.bats | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/domain/infra/abi/play.go b/pkg/domain/infra/abi/play.go index 4a146a4c6a..541822f5cc 100644 --- a/pkg/domain/infra/abi/play.go +++ b/pkg/domain/infra/abi/play.go @@ -1366,6 +1366,15 @@ func (ic *ContainerEngine) PlayKubeDown(ctx context.Context, body io.Reader, opt } } + // Remove the service container to ensure it is removed before we return for the remote case + // Needed for the clean up with podman kube play --wait in the remote case + if reports.ServiceContainerID != "" { + _, err = ic.ContainerRm(ctx, []string{reports.ServiceContainerID}, entities.RmOptions{}) + if err != nil && !errors.Is(err, define.ErrNoSuchCtr) { + return nil, err + } + } + return reports, nil } diff --git a/test/system/700-play.bats b/test/system/700-play.bats index 593f889bda..8355b183a6 100644 --- a/test/system/700-play.bats +++ b/test/system/700-play.bats @@ -619,8 +619,8 @@ spec: - name: server image: $IMAGE command: - - sleep - - "5" + - echo + - "hello" " > $fname run_podman kube play --wait $fname