mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Fallback to file for runtime config
This change ensures that we fall back to the previous behaviour of reading the existing config from the specified config file if extracting the current config from the command line fails. This fixes use cases where the containerd / crio executables are not available. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -45,9 +45,7 @@ func Flags(opts *Options) []cli.Flag {
|
||||
func Setup(c *cli.Context, o *container.Options) error {
|
||||
log.Infof("Starting 'setup' for %v", c.App.Name)
|
||||
|
||||
cfg, err := docker.New(
|
||||
docker.WithPath(o.Config),
|
||||
)
|
||||
cfg, err := getRuntimeConfig(o)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load config: %v", err)
|
||||
}
|
||||
@@ -71,9 +69,7 @@ func Setup(c *cli.Context, o *container.Options) error {
|
||||
func Cleanup(c *cli.Context, o *container.Options) error {
|
||||
log.Infof("Starting 'cleanup' for %v", c.App.Name)
|
||||
|
||||
cfg, err := docker.New(
|
||||
docker.WithPath(o.Config),
|
||||
)
|
||||
cfg, err := getRuntimeConfig(o)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to load config: %v", err)
|
||||
}
|
||||
@@ -107,3 +103,9 @@ func GetLowlevelRuntimePaths(o *container.Options) ([]string, error) {
|
||||
}
|
||||
return engine.GetBinaryPathsForRuntimes(cfg), nil
|
||||
}
|
||||
|
||||
func getRuntimeConfig(o *container.Options) (engine.Interface, error) {
|
||||
return docker.New(
|
||||
docker.WithPath(o.Config),
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user