summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2019-07-30 13:24:02 +0200
committerSascha Grunert <sgrunert@suse.com>2019-08-01 08:32:25 +0200
commit7dfaef7766871e5fd914eb0373b26db29df5bb46 (patch)
tree8a321b2b5a98b90e6054b9027f3b7f4ea61474a0
parenta622f8d345b1853401de2e533e9fbf14ef169fa2 (diff)
downloadpodman-7dfaef7766871e5fd914eb0373b26db29df5bb46.tar.gz
podman-7dfaef7766871e5fd914eb0373b26db29df5bb46.tar.bz2
podman-7dfaef7766871e5fd914eb0373b26db29df5bb46.zip
Add runtime and conmon path discovery
The `$PATH` environment variable will now used as fallback if no valid runtime or conmon path matches. The debug logs has been updated to state the used executable. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
-rw-r--r--docs/libpod.conf.5.md4
-rw-r--r--libpod.conf6
-rw-r--r--libpod/oci.go11
-rw-r--r--libpod/runtime.go16
4 files changed, 30 insertions, 7 deletions
diff --git a/docs/libpod.conf.5.md b/docs/libpod.conf.5.md
index 097d0764a..b4d562d94 100644
--- a/docs/libpod.conf.5.md
+++ b/docs/libpod.conf.5.md
@@ -16,10 +16,10 @@ libpod to manage containers.
Default OCI runtime to use if nothing is specified in **runtimes**
**runtimes**
- For each OCI runtime, specify a list of paths to look for. The first one found is used.
+ For each OCI runtime, specify a list of paths to look for. The first one found is used. If the paths are empty or no valid path was found, then the `$PATH` environment variable will be used as the fallback.
**conmon_path**=""
- Paths to search for the Conmon container manager binary
+ Paths to search for the conmon container manager binary. If the paths are empty or no valid path was found, then the `$PATH` environment variable will be used as the fallback.
**conmon_env_vars**=""
Environment variables to pass into Conmon
diff --git a/libpod.conf b/libpod.conf
index 6dd021c02..3bd3758b8 100644
--- a/libpod.conf
+++ b/libpod.conf
@@ -4,7 +4,9 @@
# Default transport method for pulling and pushing for images
image_default_transport = "docker://"
-# Paths to look for the Conmon container manager binary
+# Paths to look for the conmon container manager binary.
+# If the paths are empty or no valid path was found, then the `$PATH`
+# environment variable will be used as the fallback.
conmon_path = [
"/usr/libexec/podman/conmon",
"/usr/local/libexec/podman/conmon",
@@ -121,6 +123,8 @@ runtime = "runc"
runtime_supports_json = ["runc"]
# Paths to look for a valid OCI runtime (runc, runv, etc)
+# If the paths are empty or no valid path was found, then the `$PATH`
+# environment variable will be used as the fallback.
[runtimes]
runc = [
"/usr/bin/runc",
diff --git a/libpod/oci.go b/libpod/oci.go
index 193e66aaf..2eb004b84 100644
--- a/libpod/oci.go
+++ b/libpod/oci.go
@@ -106,8 +106,19 @@ func newOCIRuntime(name string, paths []string, conmonPath string, runtimeCfg *R
}
foundPath = true
runtime.path = path
+ logrus.Debugf("using runtime %q", path)
break
}
+
+ // Search the $PATH as last fallback
+ if !foundPath {
+ if foundRuntime, err := exec.LookPath(name); err == nil {
+ foundPath = true
+ runtime.path = foundRuntime
+ logrus.Debugf("using runtime %q from $PATH: %q", name, foundRuntime)
+ }
+ }
+
if !foundPath {
return nil, errors.Wrapf(define.ErrInvalidArg, "no valid executable found for OCI runtime %s", name)
}
diff --git a/libpod/runtime.go b/libpod/runtime.go
index bb6bfbfcc..ffdbc32f1 100644
--- a/libpod/runtime.go
+++ b/libpod/runtime.go
@@ -5,6 +5,7 @@ import (
"fmt"
"io/ioutil"
"os"
+ "os/exec"
"os/user"
"path/filepath"
"strings"
@@ -740,8 +741,19 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
}
foundConmon = true
runtime.conmonPath = path
+ logrus.Debugf("using conmon: %q", path)
break
}
+
+ // Search the $PATH as last fallback
+ if !foundConmon {
+ if conmon, err := exec.LookPath("conmon"); err == nil {
+ foundConmon = true
+ runtime.conmonPath = conmon
+ logrus.Debugf("using conmon from $PATH: %q", conmon)
+ }
+ }
+
if !foundConmon {
return errors.Wrapf(define.ErrInvalidArg,
"could not find a working conmon binary (configured options: %v)",
@@ -938,10 +950,6 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
// Initialize remaining OCI runtimes
for name, paths := range runtime.config.OCIRuntimes {
- if len(paths) == 0 {
- return errors.Wrapf(define.ErrInvalidArg, "must provide at least 1 path to OCI runtime %s", name)
- }
-
supportsJSON := false
for _, r := range runtime.config.RuntimeSupportsJSON {
if r == name {