-
Notifications
You must be signed in to change notification settings - Fork 335
Default to cdi #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Default to cdi #910
Conversation
1bb5f35
to
7343c9c
Compare
Signed-off-by: Evan Lezar <[email protected]>
323f7b8
to
3e2c4d9
Compare
Signed-off-by: Evan Lezar <[email protected]>
Signed-off-by: Evan Lezar <[email protected]>
3e2c4d9
to
23f6d28
Compare
@@ -116,6 +117,24 @@ func getDevicesFromSpec(logger logger.Interface, ociSpec oci.Spec, cfg *config.C | |||
return nil, nil | |||
} | |||
|
|||
func normalizeDeviceList(logger logger.Interface, defaultKind string, devices ...string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a code comment showing an example of what this function is doing (supposed to do).
require.NotEmpty(t, spec.Hooks, "there should be hooks in config.json") | ||
require.Equal(t, 1, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | ||
require.Empty(t, spec.Hooks, "there should be hooks in config.json") | ||
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's invert the world
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a drafty draft and I don't know what I am talking about. But we need to make progress here and you know what you are doing. So, approved!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -125,8 +125,8 @@ func TestGoodInput(t *testing.T) { | |||
// Check config.json for NVIDIA prestart hook | |||
spec, err = cfg.getRuntimeSpec() | |||
require.NoError(t, err, "should be no errors when reading and parsing spec from config.json") | |||
require.NotEmpty(t, spec.Hooks, "there should be hooks in config.json") | |||
require.Equal(t, 1, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | |||
require.Empty(t, spec.Hooks, "there should be hooks in config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Empty(t, spec.Hooks, "there should be hooks in config.json") | |
require.Empty(t, spec.Hooks, "there should be no hooks in config.json") |
require.NotEmpty(t, spec.Hooks, "there should be hooks in config.json") | ||
require.Equal(t, 1, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | ||
require.Empty(t, spec.Hooks, "there should be hooks in config.json") | ||
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | |
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "no nvidia prestart hook should be inserted into config.json") |
require.NotEmpty(t, spec.Hooks, "there should be hooks in config.json") | ||
require.Equal(t, 1, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | ||
require.Empty(t, spec.Hooks, "there should be no hooks in config.json") | ||
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "exactly one nvidia prestart hook should be inserted correctly into config.json") | |
require.Equal(t, 0, nvidiaHookCount(spec.Hooks), "no nvidia prestart hook should be inserted into config.json") |
logger.Debugf("Ignoring duplicate device %q", name) | ||
continue | ||
if cfg.AcceptDeviceListAsVolumeMounts { | ||
devices = normalizeDeviceList(logger, defaultKind, append(container.DevicesFromMounts(), container.CDIDevicesFromMounts()...)...) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this change I notice that we were only calling container.CDIDevicesFromMounts()
to construct the list of devices specified as volume mounts, but now we are also calling container.DeviceFromMounts()
-- is there a reason we weren't calling both functions prior?
No description provided.