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

jcmd missing in JRE Alpine images #3336

Closed
madduci opened this issue May 8, 2023 · 8 comments
Closed

jcmd missing in JRE Alpine images #3336

madduci opened this issue May 8, 2023 · 8 comments
Labels
alpine-linux Issues that affect or relate to the Alpine LINUX OS docker Issues related to our docker files and docker scripts wontfix Issues that have been deemed as not worth or necessary to fix

Comments

@madduci
Copy link

madduci commented May 8, 2023

What are you trying to do?

I try to run jcmd to start a JFR Recording of a running process. Image that i use:

eclipse-temurin:17.0.6_10-jre-alpine

Expected behaviour:

I can launch the tool jcmd and start a recording process.

Observed behaviour:

The tool jcmd isn't available in the image, but jfr is.

Any other comments:

Actually the Java Flight Recorder dump can only be started through the JVM Arguments, but a on-demand start through jcmd isn't possible.

Output of the issue at command line:

> docker run --rm -it --entrypoint /bin/sh eclipse-temurin:17.0.6_10-jre-alpine
/ #  jfr
Tool for working with Flight Recorder files

Before using this tool, you must have a recording file.
A file can be created by starting a recording from command line:

 java -XX:StartFlightRecording:filename=recording.jfr,duration=30s ...

A recording can also be started on already running Java Virtual Machine:

 jcmd (to list available pids)
 jcmd <pid> JFR.start

Recording data can be dumped to file using the JFR.dump command:

 jcmd <pid> JFR.dump filename=recording.jfr

The contents of the recording can then be printed, for example:

 jfr print recording.jfr

 jfr print --events CPULoad,GarbageCollection recording.jfr

 jfr print --json --events CPULoad recording.jfr

 jfr print --categories 'GC,JVM,Java*' recording.jfr

 jfr print --events 'jdk.*' --stack-depth 64 recording.jfr

 jfr summary recording.jfr

 jfr metadata recording.jfr

 jfr metadata --categories GC,Detailed

For more information about available commands, use 'jfr help'
/ # jcmd
/bin/sh: jcmd: not found

Please note that jcmd would be extremely helpful for debugging an application that runs within the Container, based on Alpine.

@github-actions github-actions bot added alpine-linux Issues that affect or relate to the Alpine LINUX OS docker Issues related to our docker files and docker scripts labels May 8, 2023
@madduci madduci changed the title jcmd missing in Alpine images jcmd missing in JRE Alpine images May 8, 2023
@RicardoMonteiroSimoes
Copy link

Well jcmd is usually only available through the JDK. But I've had problems with the jdk build of your image as well, as in it doesn't have a working jcmd setup. I had to resort to add https://github.com/jattach/jattach to the image to be able to start debugging.

@madduci
Copy link
Author

madduci commented May 9, 2023

IMHO if the command line tool jfr is in the image and the final build has the flag --enable-jfr, why shouldn't jcmd be there? There's no way to perform an on-demand dump of running processes in containers that use a JRE installation instead of a JDK one, just because the tooling is missing (you can start JFR with a JVM Argument, but what if i want to know exactly when to debug?).

It would be incredibly useful and it wonders me that until now, none has had the issue before.

@RicardoMonteiroSimoes
Copy link

Completely agree that it should definitely be there, but it somehow isnt 😛

@sxa
Copy link
Member

sxa commented May 15, 2023

Noting without further comment that this is not Alpine-specific and the jcmd binary does not exist on other JRE packages. Although if it's not working with the JDK image that would seem to be a bug.

I've had problems with the jdk build of your image as well

@RicardoMonteiroSimoes Have you verified whether this occurs with other providers' Alpine builds?

@madduci
Copy link
Author

madduci commented Sep 29, 2023

Any update on this?

@ofir-popowski
Copy link

I think this is missing from non-alpine versions as well. I'm using eclipse-temurin:17-jre and jcmd isn't there, while jfr is.

@testn
Copy link

testn commented Dec 14, 2023

Can we fix this?

@sxa
Copy link
Member

sxa commented Dec 14, 2023

There are a few points here:

  1. I have cheecked and Eclipse Temurin appears consistent with most other distributions in not including jcmd in any JRE downloaded provided
  2. The upstream openjdk project is set up to build the JRE through the legacy-jre-image target (our build scripts invokes this). The general recommendation now is that you use jlink to produce your own JRE instead of using a separate JRE, but we are continuing to ship one using the upstream legacy target as a convenience to some of our users and for consistency with other major providers. If you want to explicitly include jcmd in the jlinked runtime then you should be able to add jdk.jcmd to --add-modules parameter of jlink when you invoke it, although I haven't personally tried it.
  3. Since Temurin is very much a "vanilla" (unmodified) OpenJDK distribution we would not wish to deviate from upstream in this respect. If you wish to push for a change in behaviour of the legacy-jre-target changed, you should propose that upstream - with the justifications you have given in this issue - at the openjdk project and, if accepted, we would then pick it up by default.

@karianna karianna added the wontfix Issues that have been deemed as not worth or necessary to fix label Jan 2, 2024
@karianna karianna closed this as completed Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
alpine-linux Issues that affect or relate to the Alpine LINUX OS docker Issues related to our docker files and docker scripts wontfix Issues that have been deemed as not worth or necessary to fix
Projects
None yet
Development

No branches or pull requests

6 participants