From dc435ecb22fed044ccc348428cbd8160b36977f2 Mon Sep 17 00:00:00 2001
From: Matthew Heon <matthew.heon@pm.me>
Date: Mon, 16 May 2022 10:53:11 -0400
Subject: [PATCH] Make errors on removing exec sessions nonfatal

Removing exec sessions is guaranteed to evict them from the DB,
but in the case of a zombie process (or similar) it may error and
block removal of the container. A subsequent run of `podman rm`
would succeed (because the exec sessions have been purged from
the DB), which is potentially confusing to users. So let's just
continue, instead of erroring out, if removing exec sessions
fails.

[NO NEW TESTS NEEDED] I wouldn't want to spawn a zombie in our
test VMs even if I could.

Fixes #14252

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
---
 libpod/runtime_ctr.go | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index df7174ac6e..7e8a21a8ce 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -732,7 +732,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force, remo
 	// after setting the state to ContainerStateRemoving will prevent that the container is
 	// restarted
 	if err := c.removeAllExecSessions(); err != nil {
-		return err
+		if cleanupErr == nil {
+			cleanupErr = err
+		} else {
+			logrus.Errorf("Remove exec sessions: %v", err)
+		}
 	}
 
 	// Stop the container's storage