-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
podman container created via libpod RESTful api must set swap explicitly, otherwise it will not killed by OOM killer #13145
Comments
I think I got the reason // pkg/specgenutil/specgen.go
// func FillOutSpecGen(s *specgen.SpecGenerator, c *entities.ContainerCreateOptions, args []string) error
s.ResourceLimits.Memory, err = getMemoryLimits(s, c) The logic is: if client only specific
but so this logic does not exists for api call via
|
so, currently, the solution for the client api call is, the {
"name": "eatmem-demo",
"image": "docker.io/80x86/eatmem",
"resource_limits": {
"memory": {
"limit": 536870912,
"swap": 536870912
},
"cpu": {
"shares": 200
}
}
} after this, the container killed by OOM killer correctly. or create the contianer via the compat api: |
there is also another question, why the inspect get the result is
and podman will set both
update: I got the related code, but do not know why crun do in this way ( crun has this: swap = memory->swap;
if (cgroup2 && memory->swap != -1)
{
if (! memory->limit_present)
return crun_make_error (err, 0, "cannot set swap limit without the memory limit");
if (memory->swap < memory->limit)
return crun_make_error (err, 0, "cannot set memory+swap limit less than the memory limit");
swap -= memory->limit;
} I got the finall anwser:
this is really bad name, the inspect result uses |
A friendly reminder that this issue had no activity for 30 days. |
@rhatdan it is just a little API compability problem. I think it would be better if the behavior of the various APIs (the cli, the comat api, the libpod api) were unified. The detail is as I described in the issue "Description" section above |
Interested in opening a PR to unify them? |
A friendly reminder that this issue had no activity for 30 days. |
@cdoern PTAL |
in specgen, CLI path uses the given memory limit to define the swap value (if not already specified) add a route to this piece of code from within the api handlers resolves containers#13145 Signed-off-by: cdoern <[email protected]>
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind bug
Description
podman container created via
/libpod/containers/create
api which only specificmemory.limit
, will not setMemorySwap
(memory.swap
) to double ofMemory
limit like the cli or compat api (/containers/create
).so the cgroup v2 swap limit is always
max
, so the container will not killed by OOM even it reached the hard memory limit.after explicit set the
memory.swap
value, the created the container works as the same one created by cli.Steps to reproduce the issue:
the container will been killed soon since it need 1G memory but we only give it 512M memory (for podman, actually it is 512M memory + 512M swap limit, but since the
eatmem
will try to allocate exactly 1024M, because the containertini
init program in this container also need small bit memory, soeatmem
program will got killed)and then start it:
Describe the results you received:
eatmem-demo
not killed by OOM killer.the container created via command:
the container created via api:
Describe the results you expected:
eatmem-demo
should killed by OOM killer.cgroup v2
memory.swap.max
of the container created via api should be536870912
, notmax
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.):
The text was updated successfully, but these errors were encountered: