Repository navigation
Reject an empty device list strategy - #2002
Conversation
ceb0adf to
8da5f46
Compare
|
Thanks for the contribution. We will review the PR soon. |
abrarshivani
left a comment
There was a problem hiding this comment.
@lenamonj Thanks for contributing this. The fix looks good overall. I left a few comments, PTAL.
|
d72e5c4 covers both. AllCDIEnabled() now returns false unless at least one CDI strategy is enabled, so a set with nothing enabled no longer takes the all-CDI early return; every set with at least one strategy enabled keeps its old result. TestDeviceListStrategyFromConfigFile builds the config through NewConfig with the device-list-strategy flag at its default: an omitted deviceListStrategy comes back as envvar, an explicit empty list survives to NewDeviceListStrategies and is rejected there, and the earlier test that unmarshalled the config directly is folded into the table. |
|
@lenamonj thanks for the contribution. Can you squash your commits and make sure they are signed-off and cryptographically signed? Will trigger the GHAs after that. Thanks. |
An empty deviceListStrategy list in the config file passed validation and made DeviceListStrategies.AllCDIEnabled() report true over the empty set, so Allocate took the all-CDI early return and answered with no device list, no mounts, no CDI devices and no annotations: the container started without GPU access. NewDeviceListStrategies now rejects an empty set with an error naming the accepted strategies. AllCDIEnabled() now returns false unless at least one CDI strategy is enabled; the result is unchanged for every set with at least one strategy enabled. TestDeviceListStrategyFromConfigFile goes through NewConfig with the device-list-strategy flag at its default: an omitted deviceListStrategy gets envvar and an explicit empty list is rejected. Signed-off-by: Jeff Lenamon <jlenamon@gmail.com>
d72e5c4 to
864cddc
Compare
|
/ok to test 864cddc |
Description
An empty
deviceListStrategylist in the config file is well-formed YAML, passesNewDeviceListStrategies, andUpdateFromCLIFlagsleaves the non-nil pointer alone, so theenvvardefault never replaces it.AllCDIEnabled()is then vacuously true over the empty set,Allocatetakes the all-CDI early return, and the container starts with no device list, no mounts, no CDI devices and no annotations: no GPU access, and no error anywhere.NewDeviceListStrategiesnow rejects an empty set with an error naming the accepted strategies, whichvalidateFlagssurfaces asinvalid --device-list-strategy option.AllCDIEnabled()returns false unless at least one CDI strategy is enabled, so a set with nothing enabled cannot take the all-CDI early return either; every set with at least one strategy enabled gets the same result as before.Checklist
make lint)make test)make check-modules)make check-third-party-notices)Testing
Three unit tests in
api/config/v1/strategy_test.go:NewDeviceListStrategiesover valid, unknown, empty and nil inputs,AllCDIEnabled()over a set with nothing enabled, and the config-file path, whereNewConfiggives an omitteddeviceListStrategytheenvvardefault and leaves an explicit empty list forNewDeviceListStrategiesto reject. All three fail on main.