JBoss EAP 7 images cgroups version
Environment
-
Red Hat JBoss Enterprise Application Platform (JBoss EAP)
- 7
-
Red hat OpenShift Container Platform (RHOCP)
- 4.13+
-
cgroups
Issue
-
What cgroups version does EAP 7 images supports?
-
Calculating java heap from
resource.limit.memorydoes not work on OpenShift 4.14 that is enabled cgroupsv2 by default. Always-Xms1303m -Xmx1303mis set.
Resolution
-
Use a JBoss EAP 7/8 image compatible with cgroups v2 tags 7.4.14-5+.
-
Previously, EAP images 7.4.14-5- (e.g.
jboss-eap-7/eap74-openjdk17-runtime-openshift-rhel8:7.4.14-5) or lower, were not compatible with cgroups v2 and this was covered on This content is not included.JBEAP-26130 and has been fixed in JBoss EAP7.4.14-5container images. Same with EAP 8 images. -
Failure to detect cgroups v2 will cause Java to detect/apply the OCP Node host's settings, not from the container settings, similar to non-container-aware Java deployment settings.
-
Starting with RHOCP 4.19 cgroups v1 have been removed and only cgroups v2 is available, see RHOCP 4.19 Release Notes
Root Cause
The EAP 7 images rely not on the JDK layer to do the cgroups discovery but in a script inside that image. EAP 7's bootstrap script relies on the below script /opt/run-java/container-limits, which is cgroups v1 specific and does not work for cgroups v2 that was fixed on EAP 7.4 images tags 7.4.14-5+.
$ cat /opt/run-java/container-limits
container_memory() {
# High number which is the max limit unit which memory is supposed to be
# unbounded.
local mem_file="/sys/fs/cgroup/memory/memory.limit_in_bytes"
local max_mem_unbounded="$(max_unbounded)"
if [ -r "${mem_file}" ]; then
local max_mem="$(cat ${mem_file})"
if [ ${max_mem} -lt ${max_mem_unbounded} ]; then
echo "${max_mem}"
fi
fi
}
However, as explained in the solution Verifying Cgroup v2 Support in OpenJDK Images, Old OpenJDK images used a hard-coded file for detecting the container limit: /sys/fs/cgroup/memory/memory.limit_in_bytes. This is referenced on the code Content from github.com is not included.here. Cgroups v2 has some considerably differences with cgroups v2 given the hiearch changed, and cpuacct.usage_percpu was removed.
In fact, the Content from github.com is not included.MaxRAM PR removes the modules/jvm/bash/artifacts/opt/jboss/container/java/jvm/container-limits file completely.
Starting on EAP 8 images the OpenJDK handles this in all released JDK versions, so the MaxRAMPercentage change should be sufficient to have this working correctly also on cgroups v2.
The PR Content from github.com is not included.MaxRAM PR makes the JDK use 80% of the RAM for heap and removes the file dependency from the OpenJDK side.
Diagnostic Steps
To verify:
You should see by adding -XshowSettings:system to Java arguments:
If using cgroups v2:
Operating System Metrics:
Provider: cgroupv2
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.