From 9d222d7217847336683a22ecf81997ca9dd8b287 Mon Sep 17 00:00:00 2001 From: Domenico Calautti Date: Wed, 12 Aug 2026 19:52:10 -0400 Subject: [PATCH] docs(specgen): clarify resource_limits shape for CPU quota via libpod API This issue was originally reported back in 2023. A maintainer suggested it was really just a docs gap, so this fixes that. Reporter posted "cpu_quota" in the create body for /libpod/containers/create, following the naming of the --cpu-quota CLI flag, and it got silently ignored - the container was created fine, but the quota was never applied. Turns out there's no top-level cpu_quota field on this endpoint at all. The libpod create endpoint decodes into SpecGenerator, and CPU limits there live under the nested OCI runtime-spec shape: "resource_limits": {"cpu": {"quota": }}. The flat "cpu_quota" field only exists on the separate Docker-compatible /containers/create endpoint, so it's an easy mix-up if you're going off the CLI flag name. Verified with both a build from this branch and manual API calls: the flat field is silently dropped, the nested one works as expected. Added the correct shape as a comment on ResourceLimits in specgen.go, since that's what the libpod create endpoint's generated Swagger docs are sourced from. Fixes: #19764 Signed-off-by: Domenico Calautti --- pkg/specgen/specgen.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/specgen/specgen.go b/pkg/specgen/specgen.go index 71427c1931f..cea5dd6130f 100644 --- a/pkg/specgen/specgen.go +++ b/pkg/specgen/specgen.go @@ -576,6 +576,10 @@ type ContainerResourceConfig struct { // Can only be set as root on cgroups v1 systems, but can be set as // rootless as well for cgroups v2. // Optional. + // This follows the OCI runtime-spec LinuxResources layout, e.g. set a + // CPU quota with "resource_limits": {"cpu": {"quota": 100000}}. + // The Docker-compatible /containers/create endpoint instead takes a + // flat "cpu_quota" field - the two are not interchangeable. ResourceLimits *spec.LinuxResources `json:"resource_limits,omitempty"` // Rlimits are POSIX rlimits to apply to the container. // Optional.