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

tests/int: swap-related fixes #4188

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

kolyshkin
Copy link
Contributor

@kolyshkin kolyshkin commented Feb 2, 2024

  • Fixes a few minor issues with integration tests.
  • cgroup v2: do not set swap to 0 or unlimited when it's not available.

See individual commits for details.

Fixes #4166

Copy link
Member

@lifubang lifubang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, when we set memory to -1 in cgroupv2, it means set both memory and swap limit to max:

# try to remove memory limit
runc update test_update --memory -1
[ "$status" -eq 0 ]

@kolyshkin
Copy link
Contributor Author

Sorry, when we set memory to -1 in cgroupv2, it means set both memory and swap limit to max:

@lifubang I'm not sure why this comment is related to this PR. In here I am just fixing some issues with the test.

@kolyshkin
Copy link
Contributor Author

Sorry, when we set memory to -1 in cgroupv2, it means set both memory and swap limit to max:

# try to remove memory limit
runc update test_update --memory -1
[ "$status" -eq 0 ]

Indeed it does remove both memory and swap limits in v2, and the test is checking it (see commit commit 18ebc51).

IOW it's not a bug, it's a feature.

(and I still don't understand how this question relates to this PR)

@lifubang
Copy link
Member

and I still don't understand how this question relates to this PR

Because with your patch, I still can get an error when test this case.

This is because:
https://github.com/opencontainers/runc/blob/main/libcontainer/cgroups/utils.go#L414-L420
--memory -1 means set memory=max & swap=max.

so, need to move this test to the if condition check:

runc update test_update --memory -1

If swap is disabled, we should not run swap tests.

Fixes 4166.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1. Add "-maxdepth 2" to not dive too deep into cgroup hierarchy.

2. Add "-type f" to look for a regular file.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
In case of cgroup v2, there's no memory.swap.max in the top-level
cgroup, so we have to use find.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
When swap is being disabled (as set to 0), or set to max, ignore
non-existent memory.swap.max cgroup file.

If swap is being set explicitly to some value, do return an error like
before.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
There are cgroup v2 systems out there that do not have cgroup swap enabled,
and this test will probably fail in there.

Move it to a separate case, guarded with requires cgroups_swap.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
@kolyshkin
Copy link
Contributor Author

and I still don't understand how this question relates to this PR

Because with your patch, I still can get an error when test this case.

Thanks, I think I understand it now. Added two more commits, untested locally, please give it a try @lifubang.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ci] We should check memory.swap.max exists or not for cgroupv2
3 participants