summaryrefslogtreecommitdiff
path: root/libpod/pod_internal.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-08-24 15:15:56 -0400
committerMatthew Heon <matthew.heon@pm.me>2019-01-04 09:51:09 -0500
commitd4b2f116018e1d8e6a3c4f80f30db45934428c6b (patch)
tree66b020a3db3824d4b5c9831a1b41043aa59a5150 /libpod/pod_internal.go
parent3de560053f4b391c8386554160f61a2a086c1564 (diff)
downloadpodman-d4b2f116018e1d8e6a3c4f80f30db45934428c6b.tar.gz
podman-d4b2f116018e1d8e6a3c4f80f30db45934428c6b.tar.bz2
podman-d4b2f116018e1d8e6a3c4f80f30db45934428c6b.zip
Convert pods to SHM locks
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/pod_internal.go')
-rw-r--r--libpod/pod_internal.go19
1 files changed, 9 insertions, 10 deletions
diff --git a/libpod/pod_internal.go b/libpod/pod_internal.go
index 39a25c004..348dd2373 100644
--- a/libpod/pod_internal.go
+++ b/libpod/pod_internal.go
@@ -7,7 +7,6 @@ import (
"strings"
"time"
- "github.com/containers/storage"
"github.com/containers/storage/pkg/stringid"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -24,15 +23,6 @@ func newPod(lockDir string, runtime *Runtime) (*Pod, error) {
pod.state = new(podState)
pod.runtime = runtime
- // Path our lock file will reside at
- lockPath := filepath.Join(lockDir, pod.config.ID)
- // Grab a lockfile at the given path
- lock, err := storage.GetLockfile(lockPath)
- if err != nil {
- return nil, errors.Wrapf(err, "error creating lockfile for new pod")
- }
- pod.lock = lock
-
return pod, nil
}
@@ -55,6 +45,8 @@ func (p *Pod) save() error {
}
// Refresh a pod's state after restart
+// This cannot lock any other pod, but may lock individual containers, as those
+// will have refreshed by the time pod refresh runs.
func (p *Pod) refresh() error {
// Need to to an update from the DB to pull potentially-missing state
if err := p.runtime.state.UpdatePod(p); err != nil {
@@ -65,6 +57,13 @@ func (p *Pod) refresh() error {
return ErrPodRemoved
}
+ // Retrieve the pod's lock
+ lock, err := p.runtime.lockManager.RetrieveLock(p.config.LockID)
+ if err != nil {
+ return errors.Wrapf(err, "error retrieving lock for pod %s", p.ID())
+ }
+ p.lock = lock
+
// We need to recreate the pod's cgroup
if p.config.UsePodCgroup {
switch p.runtime.config.CgroupManager {