@@ -26,6 +26,7 @@ import (
2626 "tags.cncf.io/container-device-interface/pkg/cdi"
2727 "tags.cncf.io/container-device-interface/pkg/parser"
2828
29+ "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk-installer/container/runtime/crio"
2930 "github.com/NVIDIA/nvidia-container-toolkit/cmd/nvidia-ctk-installer/toolkit/installer"
3031 "github.com/NVIDIA/nvidia-container-toolkit/internal/config"
3132 "github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
@@ -281,7 +282,7 @@ func (t *Installer) ValidateOptions(opts *Options) error {
281282
282283// Install installs the components of the NVIDIA container toolkit.
283284// Any existing installation is removed.
284- func (t * Installer ) Install (cli * cli.Command , opts * Options ) error {
285+ func (t * Installer ) Install (cli * cli.Command , opts * Options , runtime string ) error {
285286 if t == nil {
286287 return fmt .Errorf ("toolkit installer is not initilized" )
287288 }
@@ -295,18 +296,35 @@ func (t *Installer) Install(cli *cli.Command, opts *Options) error {
295296 t .logger .Errorf ("Ignoring error: %v" , fmt .Errorf ("error removing toolkit directory: %v" , err ))
296297 }
297298
299+ var defaultRuntimeExecutable string
300+ if len (opts .ContainerRuntimeRuntimes ) > 0 {
301+ defaultRuntimeExecutable = opts .ContainerRuntimeRuntimes [0 ]
302+ }
303+
304+ // If opts.ContainerRuntimeRuntimes is empty (highly unlikely), we fall back to either runc or crun
305+ // depending on the runtime
306+ if len (defaultRuntimeExecutable ) == 0 {
307+ if runtime == crio .Name {
308+ defaultRuntimeExecutable = "crun"
309+ } else {
310+ defaultRuntimeExecutable = "runc"
311+ }
312+ }
313+
298314 // Create a toolkit installer to actually install the toolkit components.
299315 toolkit , err := installer .New (
300316 installer .WithLogger (t .logger ),
301317 installer .WithSourceRoot (t .sourceRoot ),
302318 installer .WithIgnoreErrors (opts .ignoreErrors ),
319+ installer .WithDefaultRuntimeExecutablePath (defaultRuntimeExecutable ),
303320 )
304321 if err != nil {
305322 if ! opts .ignoreErrors {
306323 return fmt .Errorf ("could not create toolkit installer: %w" , err )
307324 }
308325 t .logger .Errorf ("Ignoring error: %v" , fmt .Errorf ("could not create toolkit installer: %w" , err ))
309326 }
327+
310328 if err := toolkit .Install (t .toolkitRoot ); err != nil {
311329 if ! opts .ignoreErrors {
312330 return fmt .Errorf ("could not install toolkit components: %w" , err )
0 commit comments