rename flag to disable-hooks

Signed-off-by: Carlos Eduardo Arango Gutierrez <eduardoa@nvidia.com>
This commit is contained in:
Carlos Eduardo Arango Gutierrez 2025-05-14 12:09:05 +02:00
parent 96ecfd0b6f
commit d657e0a16a
No known key found for this signature in database
GPG Key ID: 42D9CB42F300A852
2 changed files with 24 additions and 34 deletions

View File

@ -37,7 +37,7 @@ func TestGenerateSpec(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
driverRoot := filepath.Join(moduleRoot, "testdata", "lookup", "rootfs-1") driverRoot := filepath.Join(moduleRoot, "testdata", "lookup", "rootfs-1")
disableHook := cli.NewStringSlice("enable-cuda-compat") disableHook := cli.NewStringSlice("enable-cuda-compat", "create-symlinks", "update-ldcache")
logger, _ := testlog.NewNullLogger() logger, _ := testlog.NewNullLogger()
testCases := []struct { testCases := []struct {
@ -117,7 +117,7 @@ containerEdits:
`, `,
}, },
{ {
description: "skipHook", description: "disableHooks",
options: options{ options: options{
format: "yaml", format: "yaml",
mode: "nvml", mode: "nvml",
@ -155,29 +155,6 @@ containerEdits:
deviceNodes: deviceNodes:
- path: /dev/nvidiactl - path: /dev/nvidiactl
hostPath: {{ .driverRoot }}/dev/nvidiactl hostPath: {{ .driverRoot }}/dev/nvidiactl
hooks:
- hookName: createContainer
path: /usr/bin/nvidia-cdi-hook
args:
- nvidia-cdi-hook
- create-symlinks
- --link
- libcuda.so.1::/lib/x86_64-linux-gnu/libcuda.so
- hookName: createContainer
path: /usr/bin/nvidia-cdi-hook
args:
- nvidia-cdi-hook
- update-ldcache
- --folder
- /lib/x86_64-linux-gnu
mounts:
- hostPath: {{ .driverRoot }}/lib/x86_64-linux-gnu/libcuda.so.999.88.77
containerPath: /lib/x86_64-linux-gnu/libcuda.so.999.88.77
options:
- ro
- nosuid
- nodev
- bind
`, `,
}, },
} }

View File

@ -99,21 +99,34 @@ func (l *nvcdilib) NewDriverLibraryDiscoverer(version string) (discover.Discover
var discoverers []discover.Discover var discoverers []discover.Discover
driverDotSoSymlinksDiscoverer := discover.WithDriverDotSoSymlinks( if l.HookIsSupported("create-symlinks") {
libraries, driverDotSoSymlinksDiscoverer := discover.WithDriverDotSoSymlinks(
version, libraries,
l.nvidiaCDIHookPath, version,
) l.nvidiaCDIHookPath,
discoverers = append(discoverers, driverDotSoSymlinksDiscoverer) )
discoverers = append(discoverers, driverDotSoSymlinksDiscoverer)
}
if l.HookIsSupported(HookEnableCudaCompat) { if l.HookIsSupported(HookEnableCudaCompat) {
// TODO: The following should use the version directly. // TODO: The following should use the version directly.
cudaCompatLibHookDiscoverer := discover.NewCUDACompatHookDiscoverer(l.logger, l.nvidiaCDIHookPath, l.driver) cudaCompatLibHookDiscoverer := discover.NewCUDACompatHookDiscoverer(
l.logger,
l.nvidiaCDIHookPath,
l.driver,
)
discoverers = append(discoverers, cudaCompatLibHookDiscoverer) discoverers = append(discoverers, cudaCompatLibHookDiscoverer)
} }
updateLDCache, _ := discover.NewLDCacheUpdateHook(l.logger, libraries, l.nvidiaCDIHookPath, l.ldconfigPath) if l.HookIsSupported("update-ldcache") {
discoverers = append(discoverers, updateLDCache) updateLDCache, _ := discover.NewLDCacheUpdateHook(
l.logger,
libraries,
l.nvidiaCDIHookPath,
l.ldconfigPath,
)
discoverers = append(discoverers, updateLDCache)
}
d := discover.Merge(discoverers...) d := discover.Merge(discoverers...)