From 088db091801665ce718cdcf264085f6b740ce086 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 10 May 2022 12:15:43 +0200 Subject: [PATCH] Use executable locator to find low-level runtime Signed-off-by: Evan Lezar --- internal/oci/runtime_low_level.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/internal/oci/runtime_low_level.go b/internal/oci/runtime_low_level.go index cfc3f635..795c4e14 100644 --- a/internal/oci/runtime_low_level.go +++ b/internal/oci/runtime_low_level.go @@ -18,8 +18,8 @@ package oci import ( "fmt" - "os/exec" + "github.com/NVIDIA/nvidia-container-toolkit/internal/lookup" log "github.com/sirupsen/logrus" ) @@ -43,14 +43,15 @@ func findRuntime(logger *log.Logger, candidates []string) (string, error) { return "", fmt.Errorf("at least one runtime candidate must be specified") } + locator := lookup.NewExecutableLocator(logger, "/") for _, candidate := range candidates { logger.Debugf("Looking for runtime binary '%v'", candidate) - runcPath, err := exec.LookPath(candidate) - if err == nil { - logger.Debugf("Found runtime binary '%v'", runcPath) - return runcPath, nil + targets, err := locator.Locate(candidate) + if err == nil && len(targets) > 0 { + logger.Debugf("Found runtime binary '%v'", targets) + return targets[0], nil } - logger.Debugf("Runtime binary '%v' not found: %v", candidate, err) + logger.Debugf("Runtime binary '%v' not found: %v (targets=%v)", candidate, err, targets) } return "", fmt.Errorf("no runtime binary found from candidate list: %v", candidates)