Skip to content

Reject an empty device list strategy - #2002

Merged
tariq1890 merged 1 commit into
NVIDIA:mainfrom
lenamonj:reject-empty-device-list-strategy
Sep 19, 2026
Merged

tariq1890 merged 1 commit into
NVIDIA:mainfrom
lenamonj:reject-empty-device-list-strategy

Conversation

@lenamonj

@lenamonj lenamonj commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

An empty deviceListStrategy list in the config file is well-formed YAML, passes NewDeviceListStrategies, and UpdateFromCLIFlags leaves the non-nil pointer alone, so the envvar default never replaces it. AllCDIEnabled() is then vacuously true over the empty set, Allocate takes 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.

NewDeviceListStrategies now rejects an empty set with an error naming the accepted strategies, which validateFlags surfaces as invalid --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

  • No secrets, sensitive information, or unrelated changes
  • Lint checks passing (make lint)
  • Unit tests passing (make test)
  • Go mod artifacts in-sync (make check-modules)
  • Third-party notices in-sync (make check-third-party-notices)
  • Test cases are added for new code paths

Testing

Three unit tests in api/config/v1/strategy_test.go: NewDeviceListStrategies over valid, unknown, empty and nil inputs, AllCDIEnabled() over a set with nothing enabled, and the config-file path, where NewConfig gives an omitted deviceListStrategy the envvar default and leaves an explicit empty list for NewDeviceListStrategies to reject. All three fail on main.

@copy-pr-bot

copy-pr-bot Bot commented Sep 6, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@lenamonj
lenamonj force-pushed the reject-empty-device-list-strategy branch from ceb0adf to 8da5f46 Compare September 13, 2026 17:57
@ssalagam

Copy link
Copy Markdown

Thanks for the contribution. We will review the PR soon.

@abrarshivani abrarshivani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lenamonj Thanks for contributing this. The fix looks good overall. I left a few comments, PTAL.

Comment thread api/config/v1/strategy_test.go Resolved
Comment thread api/config/v1/strategy.go Resolved
@abrarshivani abrarshivani self-assigned this Sep 17, 2026
@lenamonj

Copy link
Copy Markdown
Contributor Author

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.

@cdesiniotis

Copy link
Copy Markdown
Contributor

@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.

@abrarshivani abrarshivani left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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>
@lenamonj
lenamonj force-pushed the reject-empty-device-list-strategy branch from d72e5c4 to 864cddc Compare September 19, 2026 00:42
@lenamonj

Copy link
Copy Markdown
Contributor Author

Squashed into one commit, 864cddc, signed off and signed. Its tree is identical to d72e5c4, the head both approvals were given on.

@abrarshivani

Copy link
Copy Markdown
Contributor

/ok to test 864cddc

@tariq1890
tariq1890 merged commit 1a7c1f8 into NVIDIA:main Sep 19, 2026
12 checks passed
@lenamonj
lenamonj deleted the reject-empty-device-list-strategy branch September 19, 2026 02:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants