Add support for injecting POSIX rlimits via nvidia-container-runtime config - #2038
Open
liuxu623 wants to merge 1 commit into
Open
Add support for injecting POSIX rlimits via nvidia-container-runtime config#2038liuxu623 wants to merge 1 commit into
liuxu623 wants to merge 1 commit into
Conversation
…config
Kubernetes provides no way to set per-container POSIX rlimits, and the
common advice for RDMA workloads -- adding the IPC_LOCK capability --
is silently ineffective for non-root containers, whose effective
capability set remains empty. Raising RLIMIT_MEMLOCK on the container
runtime daemon instead changes the limit for every container on the
host, not just GPU workloads.
Add an rlimits option to the nvidia-container-runtime config that
injects the configured limits into the OCI runtime specification:
[nvidia-container-runtime]
rlimits = ["memlock=unlimited"]
Entries have the form NAME=SOFT[:HARD]; names are case-insensitive
with an optional RLIMIT_ prefix, and values are non-negative integers
or unlimited/infinity (mapped to RLIM_INFINITY). A configured entry
replaces an rlimit of the same type already present in the incoming
specification. The modifier applies in all runtime modes and is not
gated on requested devices, since workloads that need the limits
(e.g. RDMA-only containers) do not necessarily request GPUs.
The toolkit container accepts the new
--nvidia-container-runtime.rlimits flag (env
NVIDIA_CONTAINER_RUNTIME_RLIMITS) and renders the option into the
installed config, so GPU Operator users can enable it via toolkit env
without operator changes.
Addresses NVIDIA#2037
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: liuxu <liuxu623@gmail.com>
Member
|
@liuxu623 Thanks for the contribution. I don't think this belongs in
For this use case, an NRI plugin would be a better fit for the timebeing until KEP-5758 lands. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses #2037.
Motivation
Kubernetes provides no way to set per-container POSIX rlimits (kubernetes/kubernetes#3595), and the common advice for RDMA workloads — adding the
IPC_LOCKcapability — is silently ineffective for non-root containers: capabilities added viasecurityContextland in the bounding set but never in a non-root container's effective set, soibv_reg_mrstill fails withENOMEMagainst the inheritedRLIMIT_MEMLOCK(typically the 8 MiB systemd default of the container runtime daemon). Raising the limit on the daemon instead changes it for every container on the host, and containerd's per-runtimebase_runtime_specreplaces the entire default spec, which is fragile across containerd upgrades.nvidia-container-runtimealready rewrites the OCI spec per container and is naturally scoped to exactly the workloads that need pinned memory, so this adds an opt-in config option there. See #2037 for the full analysis.What this PR does
New
rlimitsoption in the runtime config:NAME=SOFT[:HARD]. Names are case-insensitive with an optionalRLIMIT_prefix; values are non-negative integers orunlimited/infinity(mapped toRLIM_INFINITY).HARDdefaults toSOFT;SOFT > HARDand duplicate types are rejected.oci.SpecModifier(internal/modifier/rlimit.go) that merges the configured entries intospec.Process.Rlimits: an entry replaces an existing rlimit of the same type, other entries in the spec are preserved.rdma/*resource) do not necessarily request GPUs.--nvidia-container-runtime.rlimits/ envNVIDIA_CONTAINER_RUNTIME_RLIMITSand renders the option into the installedconfig.toml, so GPU Operator users can enable it with no operator changes:Notes
omitemptyand the modifier is skipped when unset (nvidia-ctk config defaultoutput is identical).nvidia-container-runtimeis the runtime (RuntimeClass or default runtime). The hook-only path (docker --gpus) cannot alter rlimits, since a prestart hook runs after the process limits are set.[]stringcase to the toolkit installer's optional-config switch; the existing[]string-typed options previously fell through to the "Unexpected type" warning.Testing
go test ./internal/modifier/... ./api/config/... ./cmd/nvidia-ctk-installer/toolkit/... ./internal/runtime/...passes.🤖 Generated with Claude Code