summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <mheon@redhat.com>2021-10-20 10:29:32 -0400
committerMatthew Heon <matthew.heon@pm.me>2021-11-12 11:08:25 -0500
commitc3f3e6d3b8feabb3116dd5867f2e1117bdb5734f (patch)
tree81b421f049cdbacb7882d6e6f8835160d4862641
parentb3eaa08c5fc8164c62052aaf37776ee1813e1b47 (diff)
downloadpodman-c3f3e6d3b8feabb3116dd5867f2e1117bdb5734f.tar.gz
podman-c3f3e6d3b8feabb3116dd5867f2e1117bdb5734f.tar.bz2
podman-c3f3e6d3b8feabb3116dd5867f2e1117bdb5734f.zip
Remove infra ID from DB before removing containers
If we interrupt pod removal between removing containers and removing the whole pod, the infra ID was still in the DB, and most pod operations would try to retrieve the infra container (and would this fail). Clear the infra ID from the DB just before we remove all containers to prevent this. Fixes #12034 [NO NEW TESTS NEEDED] This is a very narrow race and I have no idea how to repro it. Signed-off-by: Matthew Heon <mheon@redhat.com>
-rw-r--r--libpod/runtime_pod_linux.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go
index 7571fdfff..a90ea6125 100644
--- a/libpod/runtime_pod_linux.go
+++ b/libpod/runtime_pod_linux.go
@@ -264,6 +264,15 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
}
}
+ // Clear infra container ID before we remove the infra container.
+ // There is a potential issue if we don't do that, and removal is
+ // interrupted between RemoveAllContainers() below and the pod's removal
+ // later - we end up with a reference to a nonexistent infra container.
+ p.state.InfraContainerID = ""
+ if err := p.save(); err != nil {
+ return err
+ }
+
// Remove all containers in the pod from the state.
if err := r.state.RemovePodContainers(p); err != nil {
// If this fails, there isn't much more we can do.