Generate CDI specification including additional GIDs#630
Conversation
|
Note: This updates the default spec version to v0.7.0 since the DRM devices generally require additional GIDs. As such, this should probably be an opt-in (or at least an opt-out) feature. |
74441f4 to
285ea44
Compare
285ea44 to
141772c
Compare
fab0c6d to
5d55813
Compare
5d55813 to
baa308b
Compare
baa308b to
ab620ac
Compare
ab620ac to
1198939
Compare
Pull Request Test Coverage Report for Build 22136305391Details
💛 - Coveralls |
1198939 to
4382fee
Compare
a2251f9 to
b3662cf
Compare
internal/edits/device.go
Outdated
| if permissionsForOther := dn.FileMode.Perm(); permissionsForOther&06 != 0 { | ||
| return []uint32{*dn.GID} | ||
| } |
There was a problem hiding this comment.
Not sure I follow this. The device is world readable or writeable if (dn.FileMode.Perm() & 06) != 0. Don't we want to add the group id for the opposite condition when the device is NOT world readable AND world writeable?
In my mind, this should be re-written as:
if rwPermissionsForOther := (dn.FileMode.Perm() & 06); rwPermissionsForOther != 06 {
return []uint32{*dn.GID}
}
but let me know if I am misunderstanding.
There was a problem hiding this comment.
Yes. You're correct. The logic is not complete. Thanks for your suggestion. Let me also add some unit tests.
Update: After adding the unit test, I decided to also introduce two helpers (isWorldReadable, isWorldWritable` for readability).
pkg/nvcdi/api.go
Outdated
| FeatureDisableMultipleCSVDevices = FeatureFlag("disable-multiple-csv-devices") | ||
|
|
||
| // NoAdditionalGIDsForDeviceNodes disables the injection of additional GIDs | ||
| // for a device node when the node is not readable by the user. |
There was a problem hiding this comment.
Same comment as before. Should we mention both read and write permissions?
s/not readable by the user/not readable and writeable by the user/
a5067df to
11b4d88
Compare
This change removes the creation of a ContainerEdits modifier when constructing a modifier from a Discoverer. Instead, the created ContainerEdits are applied directly to the incomming OCI runtime spec. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This change adds a Factory interface to the edits package. This can be used to construct CDI container edits. Currently an EmptyFactory is the only implementation and replaces direct calls to NewContainerEdits. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This change adds a FromDiscoverer method to the edits.Factory interface. This allows for a configurable way to generate CDI container edits from a discoverer. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This change adds support for injecting additional GIDs using the internal CDI representations. (Applicable for Tegra-based systems and /dev/dri devices) This is disabled by default, but can be opted in to by setting the features.allow-additional-gids feature flag. This can also be done by running sudo nvidia-ctk config --in-place --set features.allow-additional-gids Signed-off-by: Evan Lezar <elezar@nvidia.com>
This change adds a no-additional-gids-for-device-nodes feature flag to the nvidia-container-runtime feature flags as well as the nvcdi feature flags. When enabled, the check to add additional GIDs for devices that are not world-read/writeable is skipped. Signed-off-by: Evan Lezar <elezar@nvidia.com>
11b4d88 to
e559d52
Compare
Includes the change from #1655 (which could be reviewed separately).
This change adds logic to include the
AdditionalGIDsrequired for a device node in a generated CDI specification.When a device node requires specific group membership for access, a non-root user running in a container (e.g. using the
-uDocker command line argument) may not have access to the device.In the v0.7.0 CDI specification, support was added for specifying additional GIDs in the CDI specification and these changes extract the required information from the device nodes on the host if available and update the (non-root) additional GIDs in the container.
Since this MAY affect the MINIMUM required CDI spec version, a feature flag is provided to allow users to opt-out of this. In:
/etc/nvidia-container-runtime/config.tomlor using the
nvidia-ctk configCLI command:It is also exposed as an
nvcdifeature flag (no-additional-gids-for-device-nodes) which can be set at construction of the CDI spec generator:When using
nvidia-ctk cdi generateto generate CDI specs:In the case of the
nvidia-cdi-refresh.serviceupdating/etc/nvidia-container-toolkit/nvidia-cdi-refresh.envto include:will also ensure that a spec without the additional fields is generated.
The runtime support for the v0.7.0 spec is as follows: