When removing pods, free their locks

Without this we leak allocated locks, which is definitely not a
good thing.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
This commit is contained in:
Matthew Heon
2019-05-14 10:38:21 -04:00
parent a261b60cc8
commit 7b4f6f573d

View File

@ -308,5 +308,15 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
// Mark pod invalid
p.valid = false
p.newPodEvent(events.Remove)
// Deallocate the pod lock
if err := p.lock.Free(); err != nil {
if removalErr == nil {
removalErr = errors.Wrapf(err, "error freeing pod %s lock", p.ID())
} else {
logrus.Errorf("Error freeing pod %s lock: %v", p.ID(), err)
}
}
return removalErr
}