diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2017-11-24 13:39:29 -0500 |
---|---|---|
committer | Matthew Heon <matthew.heon@gmail.com> | 2017-12-04 13:39:44 -0500 |
commit | abfd18b0db8cb0ea331d90d702eab19e2157b973 (patch) | |
tree | fb0c9c3e941d0b647af9fe701e535d5db816c41f /libpod/sql_state_internal.go | |
parent | 750fc239b5da8e3f2792ae33f46a671ddf4622e3 (diff) | |
download | podman-abfd18b0db8cb0ea331d90d702eab19e2157b973.tar.gz podman-abfd18b0db8cb0ea331d90d702eab19e2157b973.tar.bz2 podman-abfd18b0db8cb0ea331d90d702eab19e2157b973.zip |
Move containers to file locks from c/storage
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/sql_state_internal.go')
-rw-r--r-- | libpod/sql_state_internal.go | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/libpod/sql_state_internal.go b/libpod/sql_state_internal.go index 3aee8f638..e4af280ae 100644 --- a/libpod/sql_state_internal.go +++ b/libpod/sql_state_internal.go @@ -4,9 +4,11 @@ import ( "database/sql" "encoding/json" "io/ioutil" + "os" "path/filepath" "time" + "github.com/containers/storage" spec "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" @@ -266,7 +268,7 @@ type scannable interface { } // Read a single container from a single row result in the database -func ctrFromScannable(row scannable, runtime *Runtime, specsDir string) (*Container, error) { +func ctrFromScannable(row scannable, runtime *Runtime, specsDir string, locksDir string) (*Container, error) { var ( id string name string @@ -384,6 +386,19 @@ func ctrFromScannable(row scannable, runtime *Runtime, specsDir string) (*Contai ctr.valid = true ctr.runtime = runtime + // Ensure the lockfile exists + lockPath := filepath.Join(locksDir, id) + _, err = os.Stat(lockPath) + if err != nil { + return nil, errors.Wrapf(err, "error performing stat on container %s lockfile", id) + } + // Open and set the lockfile + lock, err := storage.GetLockfile(lockPath) + if err != nil { + return nil, errors.Wrapf(err, "error retrieving lockfile for container %s", id) + } + ctr.lock = lock + // Retrieve the spec from disk ociSpec := new(spec.Spec) specPath := getSpecPath(specsDir, id) |