summaryrefslogtreecommitdiff
path: root/libpod/runtime.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2017-12-11 10:48:29 -0600
committerGitHub <noreply@github.com>2017-12-11 10:48:29 -0600
commit12682aa475db17d99eb0cfc5efad20e1b9f3685f (patch)
treee0f280f5f892025bea20a8cfd2c5cc4e7e1f0dc0 /libpod/runtime.go
parent62e19beeecc8f4af97388c0e715c92b582fbe685 (diff)
parent190b05209f95cf611eb5cafc4bf4cce875c74e9e (diff)
downloadpodman-12682aa475db17d99eb0cfc5efad20e1b9f3685f.tar.gz
podman-12682aa475db17d99eb0cfc5efad20e1b9f3685f.tar.bz2
podman-12682aa475db17d99eb0cfc5efad20e1b9f3685f.zip
Merge pull request #72 from mheon/file_locking
Move containers to file locks from c/storage
Diffstat (limited to 'libpod/runtime.go')
-rw-r--r--libpod/runtime.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/libpod/runtime.go b/libpod/runtime.go
index 36225bf69..d54e90722 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -25,6 +25,7 @@ type Runtime struct {
storageService *storageService
imageContext *types.SystemContext
ociRuntime *OCIRuntime
+ lockDir string
valid bool
lock sync.RWMutex
}
@@ -136,6 +137,17 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) {
}
}
+ // Make a directory to hold container lockfiles
+ lockDir := filepath.Join(runtime.config.StaticDir, "lock")
+ if err := os.MkdirAll(lockDir, 0755); err != nil {
+ // The directory is allowed to exist
+ if !os.IsExist(err) {
+ return nil, errors.Wrapf(err, "error creating runtime lockfiles directory %s",
+ lockDir)
+ }
+ }
+ runtime.lockDir = lockDir
+
// Make the per-boot files directory if it does not exist
if err := os.MkdirAll(runtime.config.TmpDir, 0755); err != nil {
// The directory is allowed to exist
@@ -154,7 +166,6 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) {
runtime.state = state
} else {
dbPath := filepath.Join(runtime.config.StaticDir, "state.sql")
- lockPath := filepath.Join(runtime.config.TmpDir, "state.lck")
specsDir := filepath.Join(runtime.config.StaticDir, "ocispec")
// Make a directory to hold JSON versions of container OCI specs
@@ -166,7 +177,7 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) {
}
}
- state, err := NewSQLState(dbPath, lockPath, specsDir, runtime)
+ state, err := NewSQLState(dbPath, specsDir, runtime.lockDir, runtime)
if err != nil {
return nil, err
}