mirror of
https://github.com/containers/podman.git
synced 2025-06-20 17:13:43 +08:00
Merge pull request #3671 from openSUSE/runtime-path-discovery
Add runtime and conmon path discovery
This commit is contained in:
@ -16,10 +16,10 @@ libpod to manage containers.
|
|||||||
Default OCI runtime to use if nothing is specified in **runtimes**
|
Default OCI runtime to use if nothing is specified in **runtimes**
|
||||||
|
|
||||||
**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**=""
|
**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**=""
|
**conmon_env_vars**=""
|
||||||
Environment variables to pass into Conmon
|
Environment variables to pass into Conmon
|
||||||
|
@ -4,7 +4,9 @@
|
|||||||
# Default transport method for pulling and pushing for images
|
# Default transport method for pulling and pushing for images
|
||||||
image_default_transport = "docker://"
|
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 = [
|
conmon_path = [
|
||||||
"/usr/libexec/podman/conmon",
|
"/usr/libexec/podman/conmon",
|
||||||
"/usr/local/libexec/podman/conmon",
|
"/usr/local/libexec/podman/conmon",
|
||||||
@ -121,6 +123,8 @@ runtime = "runc"
|
|||||||
runtime_supports_json = ["runc"]
|
runtime_supports_json = ["runc"]
|
||||||
|
|
||||||
# Paths to look for a valid OCI runtime (runc, runv, etc)
|
# 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]
|
[runtimes]
|
||||||
runc = [
|
runc = [
|
||||||
"/usr/bin/runc",
|
"/usr/bin/runc",
|
||||||
|
@ -106,8 +106,19 @@ func newOCIRuntime(name string, paths []string, conmonPath string, runtimeCfg *R
|
|||||||
}
|
}
|
||||||
foundPath = true
|
foundPath = true
|
||||||
runtime.path = path
|
runtime.path = path
|
||||||
|
logrus.Debugf("using runtime %q", path)
|
||||||
break
|
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 {
|
if !foundPath {
|
||||||
return nil, errors.Wrapf(define.ErrInvalidArg, "no valid executable found for OCI runtime %s", name)
|
return nil, errors.Wrapf(define.ErrInvalidArg, "no valid executable found for OCI runtime %s", name)
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"os/user"
|
"os/user"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
@ -740,8 +741,19 @@ func makeRuntime(ctx context.Context, runtime *Runtime) (err error) {
|
|||||||
}
|
}
|
||||||
foundConmon = true
|
foundConmon = true
|
||||||
runtime.conmonPath = path
|
runtime.conmonPath = path
|
||||||
|
logrus.Debugf("using conmon: %q", path)
|
||||||
break
|
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 {
|
if !foundConmon {
|
||||||
return errors.Wrapf(define.ErrInvalidArg,
|
return errors.Wrapf(define.ErrInvalidArg,
|
||||||
"could not find a working conmon binary (configured options: %v)",
|
"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
|
// Initialize remaining OCI runtimes
|
||||||
for name, paths := range runtime.config.OCIRuntimes {
|
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
|
supportsJSON := false
|
||||||
for _, r := range runtime.config.RuntimeSupportsJSON {
|
for _, r := range runtime.config.RuntimeSupportsJSON {
|
||||||
if r == name {
|
if r == name {
|
||||||
|
Reference in New Issue
Block a user