From bf0d35904752c2ac5c607c4a82237f074c862744 Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Thu, 14 Dec 2017 09:19:00 -0500 Subject: Remove lock existence checks when creating pods/containers Given that we don't have a good way of cleaning up locks, these could potential cause issues if we ever reuse a container or pod ID Also changes locks dir to use tmpfs, as we can't directly clean up locks Signed-off-by: Matthew Heon Closes: #138 Approved by: rhatdan --- libpod/container.go | 5 ----- libpod/pod.go | 6 ------ libpod/runtime.go | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/libpod/container.go b/libpod/container.go index ddd986b90..43ed56848 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -430,11 +430,6 @@ func newContainer(rspec *spec.Spec, lockDir string) (*Container, error) { // Path our lock file will reside at lockPath := filepath.Join(lockDir, ctr.config.ID) - // Ensure there is no conflict - file does not exist - _, err := os.Stat(lockPath) - if err == nil || !os.IsNotExist(err) { - return nil, errors.Wrapf(ErrCtrExists, "lockfile for container ID %s already exists", ctr.config.ID) - } // Grab a lockfile at the given path lock, err := storage.GetLockfile(lockPath) if err != nil { diff --git a/libpod/pod.go b/libpod/pod.go index b336c2677..15899930b 100644 --- a/libpod/pod.go +++ b/libpod/pod.go @@ -1,7 +1,6 @@ package libpod import ( - "os" "path/filepath" "github.com/containers/storage" @@ -57,11 +56,6 @@ func newPod(lockDir string) (*Pod, error) { // Path our lock file will reside at lockPath := filepath.Join(lockDir, pod.id) - // Ensure there is no conflict - file does not exist - _, err := os.Stat(lockPath) - if err == nil || !os.IsNotExist(err) { - return nil, errors.Wrapf(ErrCtrExists, "lockfile for pod ID %s already exists", pod.id) - } // Grab a lockfile at the given path lock, err := storage.GetLockfile(lockPath) if err != nil { diff --git a/libpod/runtime.go b/libpod/runtime.go index bc3a63940..b25d5f78c 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -138,7 +138,7 @@ func NewRuntime(options ...RuntimeOption) (runtime *Runtime, err error) { } // Make a directory to hold container lockfiles - lockDir := filepath.Join(runtime.config.StaticDir, "lock") + lockDir := filepath.Join(runtime.config.TmpDir, "lock") if err := os.MkdirAll(lockDir, 0755); err != nil { // The directory is allowed to exist if !os.IsExist(err) { -- cgit v1.2.3-54-g00ecf