Skip to content

Commit

Permalink
Merge branch 'explicit-cdi-enabled-flag' into 'main'
Browse files Browse the repository at this point in the history
Add --cdi-enabled option to control generating CDI spec

See merge request nvidia/container-toolkit/container-toolkit!339
  • Loading branch information
Evan Lezar committed Mar 14, 2023
2 parents 92ea8be + 08ef242 commit 738af29
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion test/container/containerd_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ testing::containerd::toolkit::run() {
--pid "container:${containerd_dind_ctr}" \
-e RUNTIME="containerd" \
-e RUNTIME_ARGS="--config=${containerd_dind_containerd_dir}/containerd.toml --socket=${containerd_dind_containerd_dir}/containerd.sock" \
-e CDI_OUTPUT_DIR="" \
--name "${containerd_test_ctr}" \
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"

Expand Down
1 change: 0 additions & 1 deletion test/container/docker_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ testing::docker::toolkit::run() {
--volumes-from "${docker_dind_ctr}" \
--pid "container:${docker_dind_ctr}" \
-e RUNTIME_ARGS="--socket ${docker_dind_socket}" \
-e CDI_OUTPUT_DIR="" \
--name "${docker_test_ctr}" \
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"

Expand Down
2 changes: 1 addition & 1 deletion test/container/toolkit_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ testing::toolkit::install() {
READLINK="greadlink"
fi

testing::docker_run::toolkit::shell 'toolkit install --toolkit-root=/usr/local/nvidia/toolkit --cdi-output-dir=""'
testing::docker_run::toolkit::shell 'toolkit install --toolkit-root=/usr/local/nvidia/toolkit'
docker run --rm -v "${shared_dir}:/work" alpine sh -c "chown -R ${uid}:${gid} /work/"

# Ensure toolkit dir is correctly setup
Expand Down
11 changes: 11 additions & 0 deletions tools/container/toolkit/toolkit.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ type options struct {
ContainerCLIDebug string
toolkitRoot string

cdiEnabled bool
cdiOutputDir string
cdiKind string
cdiVendor string
Expand Down Expand Up @@ -171,6 +172,13 @@ func main() {
Destination: &opts.toolkitRoot,
EnvVars: []string{"TOOLKIT_ROOT"},
},
&cli.BoolFlag{
Name: "cdi-enabled",
Aliases: []string{"enable-cdi"},
Usage: "enable the generation of a CDI specification",
Destination: &opts.cdiEnabled,
EnvVars: []string{"CDI_ENABLED", "ENABLE_CDI"},
},
&cli.StringFlag{
Name: "cdi-output-dir",
Usage: "the directory where the CDI output files are to be written. If this is set to '', no CDI specification is generated.",
Expand Down Expand Up @@ -592,6 +600,9 @@ func createDirectories(dir ...string) error {

// generateCDISpec generates a CDI spec for use in managemnt containers
func generateCDISpec(opts *options, nvidiaCTKPath string) error {
if !opts.cdiEnabled {
return nil
}
if opts.cdiOutputDir == "" {
log.Info("Skipping CDI spec generation (no output directory specified)")
return nil
Expand Down

0 comments on commit 738af29

Please sign in to comment.