paketo-buildpacks / libjvm

A library and helper applications that form the basis for building the different Paketo-style JVM-providing buildpacks
Apache License 2.0
18 stars 19 forks source link

Retrieve JVM and native-image crash logs that may occur at build time #404

Open dmikusa opened 3 weeks ago

dmikusa commented 3 weeks ago

Expected Behavior

When the JVM or native-image crash, the may write crash log files (i.e. hs_err_pid%d.log files). As a developer, you need to be able to see these files to debug the problem.

Current Behavior

Because this happens at build time, you cannot mount a volume and write the crash logs to that file. The files are written to the local disk, the local disk goes away after the crash and the logs are gone forever.

Possible Solution

The buildpack should create a temporary directory for these crash logs and then instruct the JVM and native-image to write crash logs to this location. If one of these processes returns a non-zero exit code, the buildpack should check the crash log location for crash log files. If it finds them, then it should write the contents to STDOUT (the files are text files) so it's available to the developer.

Steps to Reproduce

It is difficult to reproduce as you need the JVM/native-image to crash.

Motivations

Debug logs are important to understand problems.