diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-10-20 11:22:43 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-20 11:22:43 -0400 |
commit | 36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8 (patch) | |
tree | 9883d07d47e45ad05b53d1fa626d33b342ba5d5e /libpod/boltdb_state_internal.go | |
parent | 6c0b600e7d49d17db6eedd21b755b5d4f1a15b11 (diff) | |
parent | 1b4933376f4e6738ff3a0c42a2e27c6d21c07e7c (diff) | |
download | podman-36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8.tar.gz podman-36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8.tar.bz2 podman-36682115b0f3f5f7cfcc6bc4580e5a7435b9a4d8.zip |
Merge pull request #7126 from mheon/fix_missing_ociruntime
Fix missing OCI Runtime
Diffstat (limited to 'libpod/boltdb_state_internal.go')
-rw-r--r-- | libpod/boltdb_state_internal.go | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/libpod/boltdb_state_internal.go b/libpod/boltdb_state_internal.go index 9be753d26..e195ca314 100644 --- a/libpod/boltdb_state_internal.go +++ b/libpod/boltdb_state_internal.go @@ -2,7 +2,7 @@ package libpod import ( "bytes" - "path/filepath" + "os" "runtime" "strings" @@ -400,14 +400,30 @@ func (s *BoltState) getContainerFromDB(id []byte, ctr *Container, ctrsBkt *bolt. // Handle legacy containers which might use a literal path for // their OCI runtime name. runtimeName := ctr.config.OCIRuntime - if strings.HasPrefix(runtimeName, "/") { - runtimeName = filepath.Base(runtimeName) - } - ociRuntime, ok := s.runtime.ociRuntimes[runtimeName] if !ok { - // Use a MissingRuntime implementation - ociRuntime = getMissingRuntime(runtimeName, s.runtime) + runtimeSet := false + + // If the path starts with a / and exists, make a new + // OCI runtime for it using the full path. + if strings.HasPrefix(runtimeName, "/") { + if stat, err := os.Stat(runtimeName); err == nil && !stat.IsDir() { + newOCIRuntime, err := newConmonOCIRuntime(runtimeName, []string{runtimeName}, s.runtime.conmonPath, s.runtime.runtimeFlags, s.runtime.config) + if err == nil { + // The runtime lock should + // protect against concurrent + // modification of the map. + ociRuntime = newOCIRuntime + s.runtime.ociRuntimes[runtimeName] = ociRuntime + runtimeSet = true + } + } + } + + if !runtimeSet { + // Use a MissingRuntime implementation + ociRuntime = getMissingRuntime(runtimeName, s.runtime) + } } ctr.ociRuntime = ociRuntime } |