mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Use executable locator to find low-level runtime
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
b8ef6be6ea
commit
088db09180
@ -18,8 +18,8 @@ package oci
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
|
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
|
||||||
log "github.com/sirupsen/logrus"
|
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")
|
return "", fmt.Errorf("at least one runtime candidate must be specified")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
locator := lookup.NewExecutableLocator(logger, "/")
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
logger.Debugf("Looking for runtime binary '%v'", candidate)
|
logger.Debugf("Looking for runtime binary '%v'", candidate)
|
||||||
runcPath, err := exec.LookPath(candidate)
|
targets, err := locator.Locate(candidate)
|
||||||
if err == nil {
|
if err == nil && len(targets) > 0 {
|
||||||
logger.Debugf("Found runtime binary '%v'", runcPath)
|
logger.Debugf("Found runtime binary '%v'", targets)
|
||||||
return runcPath, nil
|
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)
|
return "", fmt.Errorf("no runtime binary found from candidate list: %v", candidates)
|
||||||
|
Loading…
Reference in New Issue
Block a user