diff options
author | Matthew Heon <matthew.heon@pm.me> | 2021-09-28 14:12:18 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2021-09-29 16:39:29 -0400 |
commit | 5064fd519cfd09395f9632ecb94492949b7a8367 (patch) | |
tree | 0980733659798a8d66b855dd9819bada83230de0 /libpod/boltdb_state.go | |
parent | ba74d6e6ecc2cc8e1480a466e29a078a93e24afa (diff) | |
download | podman-5064fd519cfd09395f9632ecb94492949b7a8367.tar.gz podman-5064fd519cfd09395f9632ecb94492949b7a8367.tar.bz2 podman-5064fd519cfd09395f9632ecb94492949b7a8367.zip |
Ensure pod ID bucket is properly updated on rename
As we were not updating the pod ID bucket, removing a pod with
containers still in it (including the infra container, which will
always suffer from this) will not properly update the name
registry to remove the name of any renamed containers. This
patch ensures that does not happen - all containers will be fully
removed, even if renamed.
Fixes #11750
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/boltdb_state.go')
-rw-r--r-- | libpod/boltdb_state.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libpod/boltdb_state.go b/libpod/boltdb_state.go index 5df3e8961..160f428d7 100644 --- a/libpod/boltdb_state.go +++ b/libpod/boltdb_state.go @@ -1756,6 +1756,23 @@ func (s *BoltState) SafeRewriteContainerConfig(ctr *Container, oldName, newName if err := allCtrsBkt.Put([]byte(ctr.ID()), []byte(newName)); err != nil { return errors.Wrapf(err, "error renaming container %s in all containers bucket in DB", ctr.ID()) } + if ctr.config.Pod != "" { + podsBkt, err := getPodBucket(tx) + if err != nil { + return err + } + podBkt := podsBkt.Bucket([]byte(ctr.config.Pod)) + if podBkt == nil { + return errors.Wrapf(define.ErrInternal, "bucket for pod %s does not exist", ctr.config.Pod) + } + podCtrBkt := podBkt.Bucket(containersBkt) + if podCtrBkt == nil { + return errors.Wrapf(define.ErrInternal, "pod %s does not have a containers bucket", ctr.config.Pod) + } + if err := podCtrBkt.Put([]byte(ctr.ID()), []byte(newName)); err != nil { + return errors.Wrapf(err, "error renaming container %s in pod %s members bucket", ctr.ID(), ctr.config.Pod) + } + } } } |