Skip to content

Commit 33b2479

Browse files
committed
Only generate update-ldcache hook if libraries are discovered
fixes: #373 Signed-off-by: Christopher Desiniotis <cdesiniotis@nvidia.com>
1 parent 6d1a53d commit 33b2479

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

internal/discover/ldconfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func (d ldconfig) Hooks() ([]Hook, error) {
5050
}
5151

5252
libraryFolders := uniqueFolders(getLibraryPaths(mounts))
53+
if len(libraryFolders) == 0 {
54+
return nil, nil
55+
}
5356

5457
return d.hookCreator.Create(UpdateLDCacheHook, libraryFolders...).Hooks()
5558
}

internal/discover/ldconfig_test.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,8 @@ func TestLDCacheUpdateHook(t *testing.T) {
4141
expectedHooks []Hook
4242
}{
4343
{
44-
description: "empty mounts",
45-
expectedHooks: []Hook{
46-
{
47-
Lifecycle: "createContainer",
48-
Path: testNvidiaCDIHookPath,
49-
Args: []string{"nvidia-cdi-hook", "update-ldcache"},
50-
Env: []string{"NVIDIA_CTK_DEBUG=false"},
51-
},
52-
},
44+
description: "empty mounts",
45+
expectedHooks: nil,
5346
},
5447
{
5548
description: "mount error",
@@ -101,11 +94,16 @@ func TestLDCacheUpdateHook(t *testing.T) {
10194
{
10295
description: "explicit ldconfig path is passed",
10396
ldconfigPath: testLdconfigPath,
97+
mounts: []Mount{
98+
{
99+
Path: "/usr/local/lib/libfoo.so",
100+
},
101+
},
104102
expectedHooks: []Hook{
105103
{
106104
Lifecycle: "createContainer",
107105
Path: testNvidiaCDIHookPath,
108-
Args: []string{"nvidia-cdi-hook", "update-ldcache", "--ldconfig-path", testLdconfigPath},
106+
Args: []string{"nvidia-cdi-hook", "update-ldcache", "--ldconfig-path", testLdconfigPath, "--folder", "/usr/local/lib"},
109107
Env: []string{"NVIDIA_CTK_DEBUG=false"},
110108
},
111109
},

0 commit comments

Comments
 (0)