From 446d333783e2ea3545eec35eb0cc4e3b3a168964 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Tue, 26 Feb 2019 11:20:22 +0100 Subject: oci: improve error message when the OCI runtime is not found We were previously returning the not so nice error directly from conmon. Signed-off-by: Giuseppe Scrivano --- libpod/runtime.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libpod/runtime.go b/libpod/runtime.go index 94dbf37dd..52f4523ba 100644 --- a/libpod/runtime.go +++ b/libpod/runtime.go @@ -526,6 +526,16 @@ func makeRuntime(runtime *Runtime) (err error) { if runtime.config.OCIRuntime != "" && runtime.config.OCIRuntime[0] == '/' { foundRuntime = true runtime.ociRuntimePath = OCIRuntimePath{Name: filepath.Base(runtime.config.OCIRuntime), Paths: []string{runtime.config.OCIRuntime}} + stat, err := os.Stat(runtime.config.OCIRuntime) + if err != nil { + if os.IsNotExist(err) { + return errors.Wrapf(err, "the specified OCI runtime %s does not exist", runtime.config.OCIRuntime) + } + return errors.Wrapf(err, "cannot stat the OCI runtime path %s", runtime.config.OCIRuntime) + } + if !stat.Mode().IsRegular() { + return fmt.Errorf("the specified OCI runtime %s is not a valid file", runtime.config.OCIRuntime) + } } else { // If not, look it up in the configuration. paths := runtime.config.OCIRuntimes[runtime.config.OCIRuntime] -- cgit v1.2.3-54-g00ecf