-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create .so symlinks for driver libraries in container #326
base: main
Are you sure you want to change the base?
Conversation
e20826f
to
7b5f6b3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial pass. I lost some steam near the end, but wanted to drop the comments I had for now.
// Create the '' command | ||
c := cli.Command{ | ||
Name: "create-dot-so-symlinks", | ||
Usage: "A hook to create symlinks in the container. This can be used to process CSV mount specs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this specific to CSV mount specs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is not correct. Will update.
libs, err := lookup.NewLibraryLocator( | ||
lookup.WithLogger(m.logger), | ||
lookup.WithRoot(containerRoot), | ||
lookup.WithOptional(true), | ||
).Locate("*.so." + cfg.driverVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you separate this into two calls? Chaining on separate lines like this always looks awkward to me in go code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will update.
continue | ||
} | ||
libSoPath := strings.TrimSuffix(lib, "."+cfg.driverVersion) | ||
libSoXPaths, err := filepath.Glob(libSoPath + ".[0-9]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably fine for our purposes, but should this actually be ".[0-9]+"
t include multi-digit versions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should. I was thinking one should probably rather extract the SONAME
from the target library and do it that way, but thought this heuristic was enough.
One issue is that a Glob
pattern is not a regex and the +
is not available there.
I suppose instead of including this logic, we chould just symlink .so -> .so.driverVersion
directly and bypass the .so.[0-9]
symlink here. Thoughts?
internal/config/features.go
Outdated
// DotSoSymlinks allows for the creation of .so symlinks to .so.1 driver | ||
// files to be opted out of. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically it allows them to opt-in, correct? We just happen to set the default to true so that opting-out is the "opposite" action, but the flag still exists so that one may opt-in (meaning true==create them, false==don't create them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right. I initially had this as "on-by-default" with opt-out logic, but rolled that back and didn't update the comment. Will update.
internal/config/features.go
Outdated
// featureNotControlledByEnvvar is used for features that have no envvar to | ||
// allow per-container opt-in. | ||
featureNotControlledByEnvvar = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not immediately obvious reading this top-to-bottom how this will be used. From what I can tell, we will allow the feature being added here to be controlled by an envvar (namely NVIDIA_DOT_SO_SYMLINKS
), so I'm not sure where this is going to apply yet (maybe it will be come clear later on).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Edit: I see now -- this is just giving a name to what was previously a hard coded ""
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That said -- my gut says that leaving it as a hard-coded ""
with a comment above the one place it is checked is clearer than adding this constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I initially had this as ""
in the code and thought a constant read a little bit better. Let me have another look at it.
internal/lookup/root/root.go
Outdated
libCudaPaths, err := cuda.New( | ||
r.Libraries(), | ||
).Locate(".*.*") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, this chaining looks awkward to me, but I don't feel too strongly against it if that is your preference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some of the issues were because this was out of date.
// Create the '' command | ||
c := cli.Command{ | ||
Name: "create-dot-so-symlinks", | ||
Usage: "A hook to create symlinks in the container. This can be used to process CSV mount specs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. This is not correct. Will update.
libs, err := lookup.NewLibraryLocator( | ||
lookup.WithLogger(m.logger), | ||
lookup.WithRoot(containerRoot), | ||
lookup.WithOptional(true), | ||
).Locate("*.so." + cfg.driverVersion) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Will update.
continue | ||
} | ||
libSoPath := strings.TrimSuffix(lib, "."+cfg.driverVersion) | ||
libSoXPaths, err := filepath.Glob(libSoPath + ".[0-9]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should. I was thinking one should probably rather extract the SONAME
from the target library and do it that way, but thought this heuristic was enough.
One issue is that a Glob
pattern is not a regex and the +
is not available there.
I suppose instead of including this logic, we chould just symlink .so -> .so.driverVersion
directly and bypass the .so.[0-9]
symlink here. Thoughts?
internal/config/features.go
Outdated
// featureNotControlledByEnvvar is used for features that have no envvar to | ||
// allow per-container opt-in. | ||
featureNotControlledByEnvvar = "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I initially had this as ""
in the code and thought a constant read a little bit better. Let me have another look at it.
df99dc3
to
93753a9
Compare
This change adds an opt-in feature for creating .so symlinks to all injected driver files in a contianer. If features.dot-so-symlinks = true is set in the config.toml, the creation of symlinks for driver files is enabled. This can also be triggered on a per-container basis using the envvar NVIDIA_DOT_SO_SYMLINKS=enabled. Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
93753a9
to
020f598
Compare
When
NVIDIA_DOT_SO_SYMLINKS
is not equal toenabled
:When
NVIDIA_DOT_SO_SYMLINKS=enabled
:This also works with CDI:
Note that a
--no-dot-so-symlinks
option is added to thenvidia-ctk cdi generate
command.Migrated from https://gitlab.com/nvidia/container-toolkit/container-toolkit/-/merge_requests/510
Depends on #327