Add create-soname-symlinks hook

This change adds a create-soname-symlinks hook that can be used to ensure
that the soname symlinks for injected libraries exist in a container.

This is done by calling ldconfig -n -N for the directories containing the injected
libraries.

This also ensures that libcuda.so is present in the ldcache when the update-ldcache
hook is run.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar
2025-02-27 14:38:37 +02:00
parent 5bc2f50299
commit 4bf7421a80
13 changed files with 662 additions and 31 deletions

View File

@@ -235,4 +235,26 @@ var _ = Describe("docker", Ordered, ContinueOnFailure, func() {
Expect(output).To(Equal("ModifyDeviceFiles: 0\n"))
})
})
When("A container is run using CDI", Ordered, func() {
BeforeAll(func(ctx context.Context) {
_, _, err := runner.Run("docker pull ubuntu")
Expect(err).ToNot(HaveOccurred())
})
It("should include libcuda.so in the ldcache", func(ctx context.Context) {
ldcacheOutput, _, err := runner.Run("docker run --rm -i --runtime=nvidia -e NVIDIA_VISIBLE_DEVICES=runtime.nvidia.com/gpu=all ubuntu bash -c \"ldconfig -p | grep 'libcuda.so'\"")
Expect(err).ToNot(HaveOccurred())
Expect(ldcacheOutput).ToNot(BeEmpty())
ldcacheLines := strings.Split(ldcacheOutput, "\n")
var libs []string
for _, line := range ldcacheLines {
parts := strings.SplitN(line, " (", 2)
libs = append(libs, strings.TrimSpace(parts[0]))
}
Expect(libs).To(ContainElements([]string{"libcuda.so", "libcuda.so.1"}))
})
})
})