JDK-8289695 : [TESTBUG] TestMemoryAwareness.java fails on cgroups v2 and crun
  • Type: Bug
  • Component: core-svc
  • Affected Version: 11.0.17
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • CPU: generic
  • Submitted: 2022-07-04
  • Updated: 2023-01-11
  • Resolved: 2022-07-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 11 JDK 17 JDK 20 Other
11.0.19Fixed 17.0.5Fixed 20 b06Fixed openjdk8u372Fixed
Related Reports
Duplicate :  
Relates :  
Description
Running test test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java on a cgroup v2 system and with podman (which uses crun by default) it fails the AttempOOM test case since it uses --memory-swappiness 0 which is not supported on cgroups v2.

----------System.err:(22/1176)----------
 stdout: [];
 stderr: [Error: OCI runtime error: crun: cannot set memory swappiness with cgroupv2
]
 exitValue = 126

java.lang.RuntimeException: 'Entering AttemptOOM main' missing from stdout/stderr

        at jdk.test.lib.process.OutputAnalyzer.shouldContain(OutputAnalyzer.java:163)
        at TestMemoryAwareness.testOOM(TestMemoryAwareness.java:134)
        at TestMemoryAwareness.main(TestMemoryAwareness.java:65)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
        at java.base/java.lang.Thread.run(Thread.java:829)

JavaTest Message: Test threw exception: java.lang.RuntimeException: 'Entering AttemptOOM main' missing from stdout/stderr

Comments
Fix Request (OpenJDK 8u): Please approve this test-only change (applies clean, modulo path changes). Issue observable on 8u372-dev too once JDK-8229182 integrates. 8u372-dev has cg v2 support. Setting --memory and --memory-swap to the same value (what the test already does) is sufficient to turn off swap. Test continues to pass with this (cg1 and cg2). Low risk.
20-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk8u-dev/pull/217 Date: 2022-12-20 16:59:18 +0000
20-12-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk11u-dev/pull/1602 Date: 2022-12-19 17:32:22 +0000
19-12-2022

Fix Request (OpenJDK 11u): Please approve this test-only change (applies clean). Issue observable on 11.0.17+ too which has cg v2 support. Setting --memory and --memory-swap to the same value (what the test already does) is sufficient to turn off swap. Test continues to pass with this (cg1 and cg2). Low risk.
19-12-2022

Fix Request (OpenJDK 17u): Please approve this test-only change (applies clean). Setting --memory and --memory-swap to the same value (what the test already does) is sufficient to turn off swap. Test continues to pass with this (cg1 and cg2). Low risk.
25-08-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk17u-dev/pull/645 Date: 2022-08-25 14:28:58 +0000
25-08-2022

Changeset: ac6be165 Author: Severin Gehwolf <sgehwolf@openjdk.org> Date: 2022-07-06 08:24:47 +0000 URL: https://git.openjdk.org/jdk/commit/ac6be165196457a26d837760b5f5030fe010d633
06-07-2022

Testing confirmed that the OOM test succeeds on the affected system without using memory-swappiness. So removing it is the preferred option.
05-07-2022

An alternative fix (if it's really needed to keep --memory-swappiness 0 for cgroups v1), is to only add that option on a cgroups v1 system a la TestMemoryWithCgroupV1.java
04-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9366 Date: 2022-07-04 15:03:41 +0000
04-07-2022

Docker (which uses runc) doesn't have that problem, since it merely prints a warning and continues. # docker run -ti --memory 256m --memory-swappiness 0 fedora:36 echo success WARNING: Your kernel does not support memory swappiness capabilities or the cgroup is not mounted. Memory swappiness discarded. success Small reproducer: # podman run --runtime runc -ti --memory 256m --memory-swappiness 0 fedora:36 echo success success # podman run --runtime crun -ti --memory 256m --memory-swappiness 0 fedora:36 echo success Error: OCI runtime error: crun: cannot set memory swappiness with cgroupv2 # podman info | grep cgroupVersion cgroupVersion: v2
04-07-2022