Skip to content

Commit

Permalink
Add service ctr cleanup to PlayKubeDown
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
umohnani8 committed Mar 20, 2023
1 parent 806cd13 commit 3e405a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/domain/infra/abi/play.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions test/system/700-play.bats
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ spec:
- name: server
image: $IMAGE
command:
- sleep
- "5"
- echo
- "hello"
" > $fname

run_podman kube play --wait $fname
Expand Down

0 comments on commit 3e405a2

Please sign in to comment.