Skip to content

docs: Specify resource_limits shape for CPU quota - #29490

Open
dom-calautti wants to merge 1 commit into
podman-container-tools:mainfrom
dom-calautti:fix/cpu-quota-api-documentation
Open

docs: Specify resource_limits shape for CPU quota #29490
dom-calautti wants to merge 1 commit into
podman-container-tools:mainfrom
dom-calautti:fix/cpu-quota-api-documentation

Conversation

@dom-calautti

Copy link
Copy Markdown

… API

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.

There's no top-level cpu_quota field on this endpoint at all. 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 this issue still exists: The flat field is silently dropped, the nested one works as expected (see screenshot below)
image

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

Checklist

Ensure you have completed the following checklist for your pull request to be reviewed:

  • I have read and understood our contributing guidelines and will not have more than two open PRs as a new contributor.
  • PR description, commit message, and GitHub comments are human-written, per LLM Policy
  • Certify you wrote the patch or otherwise have the right to pass it on as an open-source patch by signing all
    commits. (git commit -s). (If needed, use git commit -s --amend). The author email must match
    the sign-off email address. See CONTRIBUTING.md
    for more information.
  • Referenced issues using Fixes: #00000 in commit message (if applicable)
  • Tests have been added/updated (or no tests are needed)
  • Documentation has been updated (or no documentation changes are needed)
  • All commits pass make validatepr (format/lint checks)
  • Release note entered in the section below (or None if no user-facing changes)

Does this PR introduce a user-facing change?

None


… 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": <value>}}. 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: podman-container-tools#19764

Signed-off-by: Domenico Calautti <domeniccalautti@gmail.com>
Comment thread pkg/specgen/specgen.go
// 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

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.

This should probably go in the API swagger documentation, not here - doesn't make much sense to describe it with JSON payloads in documentation for local usage

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.

CPU Quota not being applied when creating container via the API

2 participants