Skip to content

Commit b6e5911

Browse files
Add all option to disable all hooks
Signed-off-by: Carlos Eduardo Arango Gutierrez <[email protected]>
1 parent ec49e43 commit b6e5911

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,15 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) {
287287

288288
if len(opts.disableHooks.Value()) > 0 {
289289
for _, hook := range opts.disableHooks.Value() {
290-
initOpts = append(initOpts, nvcdi.WithDisabledHook(nvcdi.HookName(hook)))
290+
if hook == "all" {
291+
initOpts = append(initOpts, nvcdi.WithDisabledHook(nvcdi.HookEnableCudaCompat))
292+
initOpts = append(initOpts, nvcdi.WithDisabledHook(nvcdi.HookCreateSymlinks))
293+
initOpts = append(initOpts, nvcdi.WithDisabledHook(nvcdi.HookUpdateLDCache))
294+
break
295+
}
296+
if nvcdi.IsValidHook(hook) {
297+
initOpts = append(initOpts, nvcdi.WithDisabledHook(nvcdi.HookName(hook)))
298+
}
291299
}
292300
}
293301

pkg/nvcdi/api.go

+15
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,19 @@ const (
4444
// HookEnableCudaCompat refers to the hook used to enable CUDA Forward Compatibility.
4545
// This was added with v1.17.5 of the NVIDIA Container Toolkit.
4646
HookEnableCudaCompat = HookName("enable-cuda-compat")
47+
// HookCreateSymlinks refers to the hook used create symlinks inside the
48+
// directory path to be mounted into a container.
49+
HookCreateSymlinks = HookName("create-symlinks")
50+
// HookUpdateLDCache refers to the hook used to Update the dynamic linker
51+
// cache inside the directory path to be mounted into a container.
52+
HookUpdateLDCache = HookName("update-ldcache")
4753
)
54+
55+
func IsValidHook(hook string) bool {
56+
switch HookName(hook) {
57+
case HookEnableCudaCompat, HookCreateSymlinks, HookUpdateLDCache:
58+
return true
59+
default:
60+
return false
61+
}
62+
}

0 commit comments

Comments
 (0)