-
Notifications
You must be signed in to change notification settings - Fork 649
[Carry #2280] Add support for CDI devices to device flag #4170
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
[Carry #2280] Add support for CDI devices to device flag #4170
Conversation
548458e
to
449537e
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.
Pull Request Overview
This PR adds support for Container Device Interface (CDI) by introducing new functions to obtain CDI specification directories across supported platforms, updating configuration and CLI flags accordingly, and integrating CDI device injection into container creation.
- Adds CDISpecDirs functions in the defaults package for Windows, Linux, FreeBSD, and Darwin.
- Updates the config structure, CLI flags, and tests to support CDI device injection.
- Integrates CDI devices handling into container run and create commands.
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
pkg/defaults/defaults_windows.go | Adds a stub CDISpecDirs function returning an empty slice for Windows. |
pkg/defaults/defaults_linux.go | Implements CDISpecDirs with distinct behavior based on rootless mode. |
pkg/defaults/defaults_freebsd.go | Provides a CDISpecDirs function returning default CDI spec directories. |
pkg/defaults/defaults_darwin.go | Provides a CDISpecDirs function returning default CDI spec directories. |
pkg/config/config.go | Introduces a new field for CDI spec directories in the configuration. |
pkg/cmd/container/run_cdi.go | Adds a function to configure CDI devices during container run. |
pkg/cmd/container/create.go | Injects the CDI devices option into the container creation process. |
pkg/api/types/container_types.go | Adds a CDIDevices field to the container create options structure. |
docs/config.md | Documents the new --cdi-spec-dirs CLI flag and configuration. |
cmd/nerdctl/testdata/cdi/vendor1.yaml | Provides an example CDI vendor file for testing purposes. |
cmd/nerdctl/main.go | Introduces the CLI flag for CDI spec directories. |
cmd/nerdctl/helpers/flagutil.go | Processes the new cdi-spec-dirs flag and integrates it into global options. |
cmd/nerdctl/container/container_run_linux_test.go | Adds tests to verify the CDI device injection functionality. |
cmd/nerdctl/container/container_create.go | Differentiates between standard devices and CDI devices during creation. |
.github/workflows/test.yml | Temporarily enables CDI support in the Docker daemon for integration tests. |
Files not reviewed (1)
- go.mod: Language not supported
9af8317
to
efe0417
Compare
efe0417
to
8e649bd
Compare
docs/config.md
Outdated
@@ -47,6 +47,7 @@ experimental = true | |||
| `host_gateway_ip` | `--host-gateway-ip` | `NERDCTL_HOST_GATEWAY_IP` | IP address that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP address of the host. It has no effect without setting --add-host | Since 1.3.0 | | |||
| `bridge_ip` | `--bridge-ip` | `NERDCTL_BRIDGE_IP` | IP address for the default nerdctl bridge network, e.g., 10.1.100.1/24 | Since 2.0.1 | | |||
| `kube_hide_dupe` | `--kube-hide-dupe` | | Deduplicate images for Kubernetes with namespace k8s.io, no more redundant <none> ones are displayed | Since 2.0.3 | | |||
| `cdi_spec_dirs` | `--cdi-spec-dirs` | | The folders to use when searching for CDI specifications. | Since 2.0.5 | |
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.
CDI needs explanation
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.
updated
8e649bd
to
c34d651
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.
@djdongjin one minor nit on help
@@ -186,6 +186,7 @@ func initRootCmdFlags(rootCmd *cobra.Command, tomlPath string) (*pflag.FlagSet, | |||
helpers.AddPersistentStringFlag(rootCmd, "host-gateway-ip", nil, nil, nil, aliasToBeInherited, cfg.HostGatewayIP, "NERDCTL_HOST_GATEWAY_IP", "IP address that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP address of the host. It has no effect without setting --add-host") | |||
helpers.AddPersistentStringFlag(rootCmd, "bridge-ip", nil, nil, nil, aliasToBeInherited, cfg.BridgeIP, "NERDCTL_BRIDGE_IP", "IP address for the default nerdctl bridge network") | |||
rootCmd.PersistentFlags().Bool("kube-hide-dupe", cfg.KubeHideDupe, "Deduplicate images for Kubernetes with namespace k8s.io") | |||
rootCmd.PersistentFlags().StringSlice("cdi-spec-dirs", cfg.CDISpecDirs, "The directories to search for CDI spec files. Defaults to /etc/cdi,/var/run/cdi") |
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.
We do not mention the defaults for CNI for eg - maybe we can remove them here as well? (or alternatively, mention the rootless defaults as well)
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.
perhaps another pr..
@@ -47,6 +47,7 @@ experimental = true | |||
| `host_gateway_ip` | `--host-gateway-ip` | `NERDCTL_HOST_GATEWAY_IP` | IP address that the special 'host-gateway' string in --add-host resolves to. Defaults to the IP address of the host. It has no effect without setting --add-host | Since 1.3.0 | | |||
| `bridge_ip` | `--bridge-ip` | `NERDCTL_BRIDGE_IP` | IP address for the default nerdctl bridge network, e.g., 10.1.100.1/24 | Since 2.0.1 | | |||
| `kube_hide_dupe` | `--kube-hide-dupe` | | Deduplicate images for Kubernetes with namespace k8s.io, no more redundant <none> ones are displayed | Since 2.0.3 | | |||
| `cdi_spec_dirs` | `--cdi-spec-dirs` | | The folders to use when searching for CDI ([container-device-interface](https://github.com/cncf-tags/container-device-interface)) specifications. | Since 2.1.0 | |
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.
folders :-)
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.
LGTM
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.
Thanks, will merge after releasing v2.0.5
Needs rebase |
This change adds support for specifying fully-qualified CDI device names in the --device flag. This allows the Container Device Interface (CDI) to be used to inject devices into container being run. Signed-off-by: Evan Lezar <elezar@nvidia.com> Enable cdi feature for Docker Signed-off-by: Evan Lezar <elezar@nvidia.com> Update go mod Signed-off-by: Evan Lezar <elezar@nvidia.com> Signed-off-by: Jin Dong <djdongjin95@gmail.com> use containerd cdi.WithCDIDevices Signed-off-by: Jin Dong <djdongjin95@gmail.com>
c34d651
to
71c646f
Compare
Carry #2280