Skip to content
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

Docker compat: Return null when swappiness is -1 #24126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

inknos
Copy link
Collaborator

@inknos inknos commented Oct 1, 2024

Fixes: #23824

Does this PR introduce a user-facing change?

`podman inspect` returns MemorySwappiness: null when it's not set

Copy link
Contributor

openshift-ci bot commented Oct 1, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: inknos
Once this PR has been reviewed and has the lgtm label, please assign mtrmac for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@inknos
Copy link
Collaborator Author

inknos commented Oct 1, 2024

I speak a very broken Go, and I am not sure whether this is the right place to fix it, so I need some expertise here. @baude @Luap99

(It makes some sense in my head though)

pkg/specgenutil/specgen.go Outdated Show resolved Hide resolved
libpod/define/container_inspect.go Outdated Show resolved Hide resolved
Fixes: containers#23824

Signed-off-by: Nicola Sella <nsella@redhat.com>
@github-actions github-actions bot added the kind/api-change Change to remote API; merits scrutiny label Oct 3, 2024
@inknos
Copy link
Collaborator Author

inknos commented Oct 3, 2024

@Luap99 makes more sense now.

However, I am checking it on my system and MemorySwappiness is 0...

$ ./bin/podman inspect practical_germain | grep Swap
               "MemorySwap": 0,
               "MemorySwappiness": 0,

Not sure if I am missing something or if this is part of a bigger problem. Shouldn't it be -1 on systems with cgroupsv2?

$ grep cgroup /proc/filesystems
nodev   cgroup
nodev   cgroup2

@inknos inknos changed the title Docker compat: Return null when swappiness is 0 Docker compat: Return null when swappiness is -1 Oct 3, 2024
@Luap99
Copy link
Member

Luap99 commented Oct 4, 2024

@Luap99 makes more sense now.

However, I am checking it on my system and MemorySwappiness is 0...

$ ./bin/podman inspect practical_germain | grep Swap
               "MemorySwap": 0,
               "MemorySwappiness": 0,

Not sure if I am missing something or if this is part of a bigger problem. Shouldn't it be -1 on systems with cgroupsv2?

$ grep cgroup /proc/filesystems
nodev   cgroup
nodev   cgroup2

Good question, I guess so.

@giuseppe @mheon WDYT?

@giuseppe
Copy link
Member

giuseppe commented Oct 4, 2024

looks like a bug. We set the memory swappiness only when there is a memory limit:

$ podman run --rm -d --name foo alpine sleep 10
3f97720574b8eab140107b2f89e7cf7e6f3944af9c780369d47f51f9e22fde2b
$ podman inspect foo | grep Swap
               "MemorySwap": 0,
               "MemorySwappiness": 0,

$ podman run --rm -d --name foo --memory 1G alpine sleep 10
6c50d6921e80e7278e191128db74e01e2f38793a73fe7d3c25fcf4fba1c1a572
$ podman inspect foo | grep Swap
               "MemorySwap": 2147483648,
               "MemorySwappiness": -1,

@inknos
Copy link
Collaborator Author

inknos commented Oct 4, 2024

looks like a bug. We set the memory swappiness only when there is a memory limit:

thanks. I can look for a fix for it

@giuseppe
Copy link
Member

giuseppe commented Oct 4, 2024

I think we could just error out when users try to set it on cgroup v2 (crun does it anyway), and hard code it to -1 for inspect.

@Luap99 @mheon what do you think?

@inknos
Copy link
Collaborator Author

inknos commented Oct 4, 2024

$ podman run --rm -d --name foo --memory-swappiness 4 alpine sleep 3
Error: OCI runtime error: crun: cannot set memory swappiness with cgroupv2

It errors out already no?

@mheon
Copy link
Member

mheon commented Oct 4, 2024

Might be cleanest to hard-code to -1 just for inspect, the resource limit code in SpecGen is pretty ugly

Copy link

github-actions bot commented Nov 4, 2024

A friendly reminder that this PR had no activity for 30 days.

@baude baude added the 5.3 label Nov 4, 2024
@baude
Copy link
Member

baude commented Nov 4, 2024

This PR has been marked for 5.3 inclusion but it must be merged prior to Nov 5 for inclusion in 5.3 RC3. PRs not merged by that date are considered on a case by case basis for backporting.

@github-actions github-actions bot removed the stale-pr label Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5.3 kind/api-change Change to remote API; merits scrutiny release-note
Projects
None yet
Development

Successfully merging this pull request may close these issues.

podman inspect should return null on some value instead of 0
5 participants