mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 13:35:00 +00:00
Add --cdi-enabled option to control generating CDI spec
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
92ea8be309
commit
08ef242afb
@ -54,7 +54,6 @@ testing::containerd::toolkit::run() {
|
|||||||
--pid "container:${containerd_dind_ctr}" \
|
--pid "container:${containerd_dind_ctr}" \
|
||||||
-e RUNTIME="containerd" \
|
-e RUNTIME="containerd" \
|
||||||
-e RUNTIME_ARGS="--config=${containerd_dind_containerd_dir}/containerd.toml --socket=${containerd_dind_containerd_dir}/containerd.sock" \
|
-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}" \
|
--name "${containerd_test_ctr}" \
|
||||||
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"
|
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"
|
||||||
|
|
||||||
|
@ -39,7 +39,6 @@ testing::docker::toolkit::run() {
|
|||||||
--volumes-from "${docker_dind_ctr}" \
|
--volumes-from "${docker_dind_ctr}" \
|
||||||
--pid "container:${docker_dind_ctr}" \
|
--pid "container:${docker_dind_ctr}" \
|
||||||
-e RUNTIME_ARGS="--socket ${docker_dind_socket}" \
|
-e RUNTIME_ARGS="--socket ${docker_dind_socket}" \
|
||||||
-e CDI_OUTPUT_DIR="" \
|
|
||||||
--name "${docker_test_ctr}" \
|
--name "${docker_test_ctr}" \
|
||||||
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"
|
"${toolkit_container_image}" "/usr/local/nvidia" "--no-daemon"
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ testing::toolkit::install() {
|
|||||||
READLINK="greadlink"
|
READLINK="greadlink"
|
||||||
fi
|
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/"
|
docker run --rm -v "${shared_dir}:/work" alpine sh -c "chown -R ${uid}:${gid} /work/"
|
||||||
|
|
||||||
# Ensure toolkit dir is correctly setup
|
# Ensure toolkit dir is correctly setup
|
||||||
|
@ -56,6 +56,7 @@ type options struct {
|
|||||||
ContainerCLIDebug string
|
ContainerCLIDebug string
|
||||||
toolkitRoot string
|
toolkitRoot string
|
||||||
|
|
||||||
|
cdiEnabled bool
|
||||||
cdiOutputDir string
|
cdiOutputDir string
|
||||||
cdiKind string
|
cdiKind string
|
||||||
cdiVendor string
|
cdiVendor string
|
||||||
@ -171,6 +172,13 @@ func main() {
|
|||||||
Destination: &opts.toolkitRoot,
|
Destination: &opts.toolkitRoot,
|
||||||
EnvVars: []string{"TOOLKIT_ROOT"},
|
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{
|
&cli.StringFlag{
|
||||||
Name: "cdi-output-dir",
|
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.",
|
Usage: "the directory where the CDI output files are to be written. If this is set to '', no CDI specification is generated.",
|
||||||
@ -592,6 +600,9 @@ func createDirectories(dir ...string) error {
|
|||||||
|
|
||||||
// generateCDISpec generates a CDI spec for use in managemnt containers
|
// generateCDISpec generates a CDI spec for use in managemnt containers
|
||||||
func generateCDISpec(opts *options, nvidiaCTKPath string) error {
|
func generateCDISpec(opts *options, nvidiaCTKPath string) error {
|
||||||
|
if !opts.cdiEnabled {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if opts.cdiOutputDir == "" {
|
if opts.cdiOutputDir == "" {
|
||||||
log.Info("Skipping CDI spec generation (no output directory specified)")
|
log.Info("Skipping CDI spec generation (no output directory specified)")
|
||||||
return nil
|
return nil
|
||||||
|
Loading…
Reference in New Issue
Block a user