EAI-8208 Give the JVM the memory limit of its container - #814
Merged
Conversation
Ubuntu 26.04 has a kernel built without CONFIG_MEMCG_V1 and CONFIG_CPUSETS_V1, so it does not list the memory and cpuset controllers in /proc/cgroups. JDK 21 reads that file to know whether it runs in a container. It finds no entry, decides it is not containerized, and sizes the heap from the memory of the host. Keycloak then passes its 2Gi limit and the kernel kills it. The crash loop blocks airm-configure, which never creates the secret airm-rabbitmq-common-vhost-user, so airm-agent and airm-api fail as well. MaxRAM tells the JVM how much memory to assume, and the Downward API reads the value from the limit of this container, so the limit stays in one place. The heap becomes 512.00M on Ubuntu 26.04, which is the value that Ubuntu 24.04 already produces without any option, so the change does nothing there.
lauri-amd
approved these changes
Aug 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related:
What
Keycloak gets the memory limit of its own container through
-XX:MaxRAM, andthe value comes from the Downward API, so the limit stays in one place.
Why
On Ubuntu 26.04 the Keycloak pod is
OOMKilledagain and again at its 2Gilimit. The crash loop blocks
airm-configure, which never creates the secretairm-rabbitmq-common-vhost-user, soairm-agentandairm-apifail as well.One JVM stops four workloads. The same chart, the same limits and the same image
are healthy on Ubuntu 24.04.
Ubuntu 26.04 has kernel 7.0, built without
CONFIG_MEMCG_V1andCONFIG_CPUSETS_V1. That kernel does not list thememoryandcpusetcontrollers in
/proc/cgroups. JDK 21 reads that file to decide whether it runsin a container. It finds no entry, decides it is not containerized, and sizes the
heap from the memory of the host.
With one pod manifest,
limits.memory: 2Gi, and the container reading/sys/fs/cgroup/memory.max = 2147483648on both releases:java -Xlog:os+container=trace -versionon 26.04 gives the reason:Why this option and not another
Measured in the Keycloak image with JDK 21.0.6, at a 2Gi limit:
-XX:MaxRAMPercentage=70-Xmx1g-XX:MaxRAM=2147483648-Xmxwrites the heap size in a second place, so it does not follow a laterchange of
limits.memory.-XX:MaxRAMfrom the Downward API follows it.JAVA_OPTS_APPENDand notJAVA_OPTS, because the image sets its own defaultsin
JAVA_OPTS.Why not a newer image
No released Keycloak image carries a fixed JDK yet. Measured on a 26.04 node:
quay.io/keycloak/keycloak:26.0.0(in use)quay.io/keycloak/keycloak:26.0.8quay.io/keycloak/keycloak:26.2quay.io/keycloak/keycloak:26.4(newest)eclipse-temurin:21-jreeclipse-temurin:25-jreRemove the two entries when the image carries JDK 21.0.11 or later. Check with:
Test
Found while testing cluster-bloom PR 306 (EAI-8203) with cluster-forge v2.2.2 on
two two-node clusters, one per Ubuntu release.
The change was applied to the running deployment on the 26.04 cluster:
1/1 Runningwith 0 restarts.option, so the change does nothing on 24.04 and needs no release condition.
airm-configurecompleted, the secretairm-rabbitmq-common-vhost-userappeared, and
airm-agentandairm-apistarted. The 26.04 cluster then hadthe same 53 of 54 ArgoCD applications Synced and Healthy as the 24.04 cluster.
The stack holds one JVM, so this is the only workload that needs the change
today:
Jira: https://amd.atlassian.net/browse/EAI-8208