Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[OPENJDK-2968] JAVA_ARGS has no effect in ubi9/openjdk-17-runtime #483

Open
linustornkrantz opened this issue Apr 15, 2024 · 5 comments
Open

Comments

@linustornkrantz
Copy link

linustornkrantz commented Apr 15, 2024

According to https://jboss-container-images.github.io/openjdk/ubi9/ubi9-openjdk-17-runtime.html, it should be possible to set arguments with JAVA_ARGS in ubi9/openjdk-17-runtime, just as it works in ubi9/openjdk-17. However, JAVA_ARGS has no effect in ubi9/openjdk-17-runtime.

To reproduce:

cat > ArgsTest.java <<EOF
import java.util.Arrays;

class ArgsTest {

    public static void main(String[] args) {
        System.out.println("Number of args: " + args.length);
        Arrays.stream(args).forEach(System.out::println);
    }

}
EOF

javac ArgsTest.java

podman run -v ./:/app -e JAVA_APP_DIR=/app/ -e JAVA_MAIN_CLASS=ArgsTest -e JAVA_ARGS=Hello registry.access.redhat.com/ubi9/openjdk-17:1.18-1

podman run -v ./:/app -e JAVA_APP_DIR=/app/ -e JAVA_MAIN_CLASS=ArgsTest -e JAVA_ARGS=Hello registry.access.redhat.com/ubi9/openjdk-17-runtime:1.18-1

For ubi9/openjdk-17, this produces:

Starting the Java application using /opt/jboss/container/java/run/run-java.sh ...
INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp ".:/app//*" ArgsTest Hello
INFO running in /app
Number of args: 1
Hello

For ubi9/openjdk-17-runtime, this produces:

INFO exec -a "java" java -XX:MaxRAMPercentage=80.0 -XX:+UseParallelGC -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -XX:+ExitOnOutOfMemoryError -cp ".:/app//*" ArgsTest 
INFO running in /app
Number of args: 0
@jerboaa
Copy link
Contributor

jerboaa commented Apr 15, 2024

@jhuttana Please take a look at this. Thanks!

@jhuttana
Copy link
Contributor

@jhuttana Please take a look at this. Thanks!

Sure

@schedin
Copy link

schedin commented Apr 15, 2024

If I where to guess this is because the ubi9/openjdk-17 uses the source 2 image start script that has support for JAVA_ARGS:

[builder@97032af7e5d2 operator]$ podman inspect registry.access.redhat.com/ubi9/openjdk-17:1.18-1 | grep CMD
                    "created_by": "/bin/sh -c #(nop) CMD [\"/bin/bash\"]",
                    "created_by": "/bin/sh -c #(nop) CMD [\"/usr/local/s2i/run\"]",

exec "${JBOSS_CONTAINER_JAVA_RUN_MODULE}/run-java.sh" $args ${JAVA_ARGS}

But the ubi9/openjdk-17-runtime uses another start script does not have support for JAVA_ARGS. It only has support for "normal" arguments passed via CMD:

[builder@97032af7e5d2 operator]$ podman inspect registry.access.redhat.com/ubi9/openjdk-17-runtime:1.18-1 | grep CMD
                    "created_by": "/bin/sh -c #(nop) CMD [\"/bin/bash\"]",
                    "created_by": "/bin/sh -c #(nop) CMD [\"/opt/jboss/container/java/run/run-java.sh\"]",

exec -a "${procname}" java $(get_java_options) -cp "$(get_classpath)" ${args} $*

@jmtd
Copy link
Member

jmtd commented Apr 15, 2024

@schedin 's analysis looks correct; JAVA_ARGS is handled in the s2i/run script, rather than run-java.sh. Awkward!

We should probably move all the logic to run-java.sh and have the s2i CMD be as thin as possible, or get rid of it.

@jmtd
Copy link
Member

jmtd commented Apr 15, 2024

Corresponding JIRA :https://issues.redhat.com/browse/OPENJDK-2968

@jmtd jmtd changed the title JAVA_ARGS has no effect in ubi9/openjdk-17-runtime [OPENJDK-2968] JAVA_ARGS has no effect in ubi9/openjdk-17-runtime Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants