diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2022-04-29 08:49:33 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 08:49:33 -0400 |
commit | 59f154a095a965d7db3b11a61fea183ff42f83a7 (patch) | |
tree | 604efbb265284bda61530727ec23089272bc8f0d | |
parent | ab3e072a0c3d321fd12cbd1f6ef8e322c6d9214a (diff) | |
parent | 384c2359b7adf9441e949128d58396872b30fc84 (diff) | |
download | podman-59f154a095a965d7db3b11a61fea183ff42f83a7.tar.gz podman-59f154a095a965d7db3b11a61fea183ff42f83a7.tar.bz2 podman-59f154a095a965d7db3b11a61fea183ff42f83a7.zip |
Merge pull request #14061 from giuseppe/unlock-before-pod-cgroup-cleanup
libpod: unlock containers when removing pod
-rw-r--r-- | libpod/runtime_pod_linux.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go index 2bbccfdf6..62ec7df60 100644 --- a/libpod/runtime_pod_linux.go +++ b/libpod/runtime_pod_linux.go @@ -199,10 +199,15 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, // Go through and lock all containers so we can operate on them all at // once. // First loop also checks that we are ready to go ahead and remove. + containersLocked := true for _, ctr := range ctrs { ctrLock := ctr.lock ctrLock.Lock() - defer ctrLock.Unlock() + defer func() { + if containersLocked { + ctrLock.Unlock() + } + }() // If we're force-removing, no need to check status. if force { @@ -304,6 +309,12 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, } } + // let's unlock the containers so if there is any cleanup process, it can terminate its execution + for _, ctr := range ctrs { + ctr.lock.Unlock() + } + containersLocked = false + // Remove pod cgroup, if present if p.state.CgroupPath != "" { logrus.Debugf("Removing pod cgroup %s", p.state.CgroupPath) @@ -332,7 +343,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, } } if err == nil { - if err := conmonCgroup.Delete(); err != nil { + if err = conmonCgroup.Delete(); err != nil { if removalErr == nil { removalErr = errors.Wrapf(err, "error removing pod %s conmon cgroup", p.ID()) } else { |