Skip to content

Commit 9a06768

Browse files
author
Evan Lezar
committed
Merge branch 'fix-nvidia-ctk-path' into 'main'
Only use configured nvidia-ctk path if it is a full path See merge request nvidia/container-toolkit/container-toolkit!281
2 parents 763e493 + 0c8379f commit 9a06768

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

internal/discover/hooks.go

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,24 @@ func CreateNvidiaCTKHook(executable string, hookName string, additionalArgs ...s
3939
}
4040

4141
// FindNvidiaCTK locates the nvidia-ctk executable to be used in hooks.
42-
// If an override is specified, this is used instead.
43-
func FindNvidiaCTK(logger *logrus.Logger, override string) string {
44-
if override != "" {
45-
logger.Debugf("Using specified NVIDIA Container Toolkit CLI path %v", override)
46-
return override
42+
// If an nvidia-ctk path is specified as an absolute path, it is used directly
43+
// without checking for existence of an executable at that path.
44+
func FindNvidiaCTK(logger *logrus.Logger, nvidiaCTKPath string) string {
45+
if filepath.IsAbs(nvidiaCTKPath) {
46+
logger.Debugf("Using specified NVIDIA Container Toolkit CLI path %v", nvidiaCTKPath)
47+
return nvidiaCTKPath
4748
}
4849

50+
logger.Debugf("Locating NVIDIA Container Toolkit CLI as %v", nvidiaCTKPath)
4951
lookup := lookup.NewExecutableLocator(logger, "")
5052
hookPath := nvidiaCTKDefaultFilePath
51-
targets, err := lookup.Locate(nvidiaCTKExecutable)
53+
targets, err := lookup.Locate(nvidiaCTKPath)
5254
if err != nil {
53-
logger.Warnf("Failed to locate %v: %v", nvidiaCTKExecutable, err)
55+
logger.Warnf("Failed to locate %v: %v", nvidiaCTKPath, err)
5456
} else if len(targets) == 0 {
55-
logger.Warnf("%v not found", nvidiaCTKExecutable)
57+
logger.Warnf("%v not found", nvidiaCTKPath)
5658
} else {
57-
logger.Debugf("Found %v candidates: %v", nvidiaCTKExecutable, targets)
59+
logger.Debugf("Found %v candidates: %v", nvidiaCTKPath, targets)
5860
hookPath = targets[0]
5961
}
6062
logger.Debugf("Using NVIDIA Container Toolkit CLI path %v", hookPath)

internal/discover/ldconfig.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,15 @@ import (
2121
"path/filepath"
2222
"strings"
2323

24-
"github.com/NVIDIA/nvidia-container-toolkit/internal/lookup"
2524
"github.com/sirupsen/logrus"
2625
)
2726

2827
// NewLDCacheUpdateHook creates a discoverer that updates the ldcache for the specified mounts. A logger can also be specified
2928
func NewLDCacheUpdateHook(logger *logrus.Logger, mounts Discover, cfg *Config) (Discover, error) {
3029
d := ldconfig{
3130
logger: logger,
31+
nvidiaCTKPath: FindNvidiaCTK(logger, cfg.NvidiaCTKPath),
3232
mountsFrom: mounts,
33-
lookup: lookup.NewExecutableLocator(logger, cfg.Root),
34-
nvidiaCTKPath: cfg.NvidiaCTKPath,
3533
}
3634

3735
return &d, nil
@@ -40,9 +38,8 @@ func NewLDCacheUpdateHook(logger *logrus.Logger, mounts Discover, cfg *Config) (
4038
type ldconfig struct {
4139
None
4240
logger *logrus.Logger
43-
mountsFrom Discover
44-
lookup lookup.Locator
4541
nvidiaCTKPath string
42+
mountsFrom Discover
4643
}
4744

4845
// Hooks checks the required mounts for libraries and returns a hook to update the LDcache for the discovered paths.

internal/edits/edits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func (e *edits) Modify(spec *ociSpecs.Spec) error {
108108
}
109109
e.logger.Infof("Hooks:")
110110
for _, hook := range e.Hooks {
111-
e.logger.Infof("Injecting %v", hook.Args)
111+
e.logger.Infof("Injecting %v %v", hook.Path, hook.Args)
112112
}
113113

114114
return e.Apply(spec)

0 commit comments

Comments
 (0)