Skip to content

Commit 16f82d4

Browse files
committed
Override MaxRAMPercentage
Override MaxRAMPercentage for JVMs invoked by Maven to avoid attempting to use too much of the pod RAM. Signed-off-by: Jonathan Dowland <[email protected]>
1 parent 135869f commit 16f82d4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

modules/maven/default/artifacts/opt/jboss/container/maven/default/maven.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function maven_init_var_MAVEN_SETTINGS_XML() {
4141
}
4242

4343
function maven_init_var_MAVEN_OPTS() {
44-
export MAVEN_OPTS="${MAVEN_OPTS:-$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options)}"
44+
export MAVEN_OPTS="${MAVEN_OPTS:-$(${JBOSS_CONTAINER_JAVA_JVM_MODULE}/java-default-options) -XX:MaxRAMPercentage=25.0}"
4545
}
4646

4747
function maven_init_var_MAVEN_ARGS() {

tests/features/java/memory.feature

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1-
@openjdk
2-
@redhat-openjdk-18
3-
@ubi8
41
Feature: OPENJDK-559 JVM Memory tests
52

3+
@ubi8
64
Scenario: Check default JVM max heap configuration
75
Given container is started as uid 1000
86
Then container log should contain -XX:MaxRAMPercentage=80.0
97

8+
@ubi8
109
Scenario: Check configured JVM max heap configuration
1110
Given container is started with env
1211
| variable | value |
1312
| JAVA_MAX_MEM_RATIO | 90.0 |
1413
Then container log should contain -XX:MaxRAMPercentage=90.0
1514

15+
@ubi8
1616
Scenario: Check default JVM initial heap configuration is unspecified
1717
Given container is started as uid 1000
1818
Then container log should not contain -XX:InitialRAMPercentage
1919
And container log should not contain -Xms
2020

21+
@ubi8
2122
Scenario: Check configured JVM max heap configuration
2223
Given container is started with env
2324
| variable | value |
2425
| JAVA_INITIAL_MEM_RATIO | 25.0 |
2526
Then container log should contain -XX:InitialRAMPercentage=25.0
2627

28+
@ubi8
2729
Scenario: check JAVA_MAX_INITIAL_MEM overrides JAVA_INITIAL_MEM_RATIO
2830
Given container is started with env
2931
| variable | value |
3032
| JAVA_INITIAL_MEM_RATIO | 25.0 |
3133
| JAVA_MAX_INITIAL_MEM | 4096m |
3234
Then container log should contain -Xms4096m
3335
And container log should not contain -XX:InitialRAMPercentage=25.0
36+
37+
# Not the runtime images
38+
@ubi8/openjdk-8
39+
@ubi8/openjdk-11
40+
@ubi8/openjdk-17
41+
Scenario: Ensure Maven doesn't use MaxRAMPercentage=80
42+
Given s2i build https://github.com/jboss-openshift/openshift-examples from spring-boot-sample-simple
43+
Then s2i build log should match regex INFO Using MAVEN_OPTS.*-XX:MaxRAMPercentage=25.0$

0 commit comments

Comments
 (0)