Skip to content

Conversation

ajoy-zero
Copy link

@ajoy-zero ajoy-zero commented Jun 10, 2025

What problem does this PR solve?

Fix memory limit detection logic for cgroupfs Close #8 Close #5
fix: use ./memStress in exec.Command to avoid PATH not found error Close #7

What's changed and how it works?

  • Fix memory limit detection logic for cgroup v1: treat 0x7FFFFFFFFFFFF000 (9223372036854771712) as unlimited.
  • Ensure cgroup v2 uses "max" as unlimited.
  • Update comments to English for better readability.
  • This ensures memory stress respects container memory limits correctly.

Related changes

  • This change also requires further updates to the chaos-mesh

Tests

  • Manual test

Note: A temporary --print-mem flag was added during development for testing purposes. It has been removed before finalizing the PR.

The situation where cgroup1 is restricted

image

There are no restrictions on cgroup1
image
image

(cgroup2) Docker container with a 32GB memory limit, result as follows (host has ~8GB physical memory):

image
image

(cgroup2) Docker container with a 10GB memory limit, result as follows (host has ~2GB physical memory):

image
image

@chaotic-prow
Copy link

chaotic-prow bot commented Jun 10, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: ajoy-zero

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

- Fix memory limit detection logic for cgroup v1: treat 0x7FFFFFFFFFFFF000 (9223372036854771712) as unlimited.
- Ensure cgroup v2 uses "max" as unlimited.
- Update comments to English for better readability.
- This ensures memory stress respects container memory limits correctly.

Signed-off-by: xiejunqiao <[email protected]>
- Change exec.Command("memStress", ...) to exec.Command("./memStress", ...)
- This avoids "executable file not found in $PATH" error when current directory is not in $PATH
- No impact on other features

Signed-off-by: xiejunqiao <[email protected]>
@Andrewmatilde
Copy link
Member

@STRRL PTAL

@STRRL STRRL requested a review from Andrewmatilde August 19, 2025 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants