Increase priority of ld.so.conf.d config file

This change ensures that the created /etc/ld.so.conf.d file
has a higher priority to ensure that the injected libraries
take precendence over non-compat libraries.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2024-06-04 12:57:58 +02:00
parent dfc8e22e12
commit 4f0de9f1ef

View File

@ -153,8 +153,11 @@ func (m command) resolveLDConfigPath(path string) string {
return strings.TrimPrefix(config.NormalizeLDConfigPath("@"+path), "@") return strings.TrimPrefix(config.NormalizeLDConfigPath("@"+path), "@")
} }
// createConfig creates (or updates) /etc/ld.so.conf.d/nvcr-<RANDOM_STRING>.conf in the container // createConfig creates (or updates) /etc/ld.so.conf.d/00-nvcr-<RANDOM_STRING>.conf in the container
// to include the required paths. // to include the required paths.
// Note that the 00-nvcr prefix is chosen to ensure that these libraries have
// a higher precedence than other libraries on the system but are applied AFTER
// 00-cuda-compat.conf.
func (m command) createConfig(root string, folders []string) error { func (m command) createConfig(root string, folders []string) error {
if len(folders) == 0 { if len(folders) == 0 {
m.logger.Debugf("No folders to add to /etc/ld.so.conf") m.logger.Debugf("No folders to add to /etc/ld.so.conf")
@ -165,7 +168,7 @@ func (m command) createConfig(root string, folders []string) error {
return fmt.Errorf("failed to create ld.so.conf.d: %v", err) return fmt.Errorf("failed to create ld.so.conf.d: %v", err)
} }
configFile, err := os.CreateTemp(filepath.Join(root, "/etc/ld.so.conf.d"), "nvcr-*.conf") configFile, err := os.CreateTemp(filepath.Join(root, "/etc/ld.so.conf.d"), "00-nvcr-*.conf")
if err != nil { if err != nil {
return fmt.Errorf("failed to create config file: %v", err) return fmt.Errorf("failed to create config file: %v", err)
} }