Skip to content

Commit e33f15a

Browse files
authored
Merge pull request #1002 from elezar/improve-update-ldcache-args
Fix update-ldcache arguments
2 parents 77bf915 + 995e563 commit e33f15a

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

cmd/nvidia-cdi-hook/update-ldcache/update-ldcache.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,20 @@ func (m command) run(c *cli.Context, cfg *options) error {
109109
}
110110

111111
containerRootDir, err := s.GetContainerRoot()
112-
if err != nil {
112+
if err != nil || containerRootDir == "" || containerRootDir == "/" {
113113
return fmt.Errorf("failed to determined container root: %v", err)
114114
}
115115

116116
ldconfigPath := m.resolveLDConfigPath(cfg.ldconfigPath)
117-
args := []string{filepath.Base(ldconfigPath)}
118-
if containerRootDir != "" {
119-
args = append(args, "-r", containerRootDir)
117+
args := []string{
118+
filepath.Base(ldconfigPath),
119+
// Run ldconfig in the container root directory on the host.
120+
"-r", containerRootDir,
121+
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
122+
// be configured to use a different config file by default.
123+
// Note that since we apply the `-r {{ .containerRootDir }}` argument, /etc/ld.so.conf is
124+
// in the container.
125+
"-f", "/etc/ld.so.conf",
120126
}
121127

122128
containerRoot := containerRoot(containerRootDir)
@@ -138,10 +144,6 @@ func (m command) run(c *cli.Context, cfg *options) error {
138144
args = append(args, folders...)
139145
}
140146

141-
// Explicitly specify using /etc/ld.so.conf since the host's ldconfig may
142-
// be configured to use a different config file by default.
143-
args = append(args, "-f", "/etc/ld.so.conf")
144-
145147
return m.SafeExec(ldconfigPath, args, nil)
146148
}
147149

0 commit comments

Comments
 (0)