mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Move ResolveAutoMode to info package
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -69,7 +69,7 @@ func NewExperimentalModifier(logger *logrus.Logger, cfg *config.Config, ociSpec
|
||||
|
||||
var d discover.Discover
|
||||
|
||||
switch resolveAutoDiscoverMode(logger, cfg.NVIDIAContainerRuntimeConfig.DiscoverMode) {
|
||||
switch info.ResolveAutoMode(logger, cfg.NVIDIAContainerRuntimeConfig.DiscoverMode) {
|
||||
case "legacy":
|
||||
legacyDiscoverer, err := discover.NewLegacyDiscoverer(logger, config)
|
||||
if err != nil {
|
||||
@@ -178,22 +178,3 @@ func checkRequirements(logger *logrus.Logger, image *image.CUDA) error {
|
||||
|
||||
return r.Assert()
|
||||
}
|
||||
|
||||
// resolveAutoDiscoverMode determines the correct discover mode for the specified platform if set to "auto"
|
||||
func resolveAutoDiscoverMode(logger *logrus.Logger, mode string) (rmode string) {
|
||||
if mode != "auto" {
|
||||
return mode
|
||||
}
|
||||
defer func() {
|
||||
logger.Infof("Auto-detected discover mode as '%v'", rmode)
|
||||
}()
|
||||
|
||||
isTegra, reason := info.IsTegraSystem()
|
||||
logger.Debugf("Is Tegra-based system? %v: %v", isTegra, reason)
|
||||
|
||||
if isTegra {
|
||||
return "csv"
|
||||
}
|
||||
|
||||
return "legacy"
|
||||
}
|
||||
|
||||
@@ -318,32 +318,3 @@ func TestExperimentalModifier(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestResolveDiscoverMode(t *testing.T) {
|
||||
logger, _ := testlog.NewNullLogger()
|
||||
|
||||
testCases := []struct {
|
||||
description string
|
||||
mode string
|
||||
expectedMode string
|
||||
}{
|
||||
{
|
||||
description: "non-auto resolves to input",
|
||||
mode: "not-auto",
|
||||
expectedMode: "not-auto",
|
||||
},
|
||||
// TODO: The following test is brittle in that it will break on Tegra-based systems.
|
||||
// {
|
||||
// description: "auto resolves to legacy",
|
||||
// mode: "auto",
|
||||
// expectedMode: "legacy",
|
||||
// },
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
t.Run(tc.description, func(t *testing.T) {
|
||||
mode := resolveAutoDiscoverMode(logger, tc.mode)
|
||||
require.EqualValues(t, tc.expectedMode, mode)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user