According to Google search, e.g. https://medium.com/faun/java-application-optimization-on-kubernetes-on-the-example-of-a-spring-boot-microservice-cf3737a2219c kubectl scale alone doesn't provide out of the box graceful shutdown for applications inside pod.
Instead of relying on JVM shutdown hook execution, you can explicitly send dump command to JaCoCo agent prior to shutdown. On Monday, August 10, 2020 at 6:43:01 PM UTC+3 Jennie wrote: > Thanks for your reply. kubectl scale deployment mypod -replicas=0 should > be the way to gracefully shutdown the pod/container but it does't flush the > .exec data either. I will re-read some of provided links here > > > On Monday, August 10, 2020 at 11:29:28 AM UTC-4, Evgeny Mandrikov wrote: >> >> Hi, >> >> This has been answered an enormous amount of times - please use search. >> For example >> https://groups.google.com/forum/#!msg/jacoco/Jdgz90jw3ZY/YUAvvA7KBwAJ >> https://groups.google.com/forum/#!msg/jacoco/q3xjdkOH_0g/3UMLI_9NAgAJ >> https://groups.google.com/d/msg/jacoco/DZNqIGaoPKQ/5EbhZTAaAwAJ >> etc. >> >> JaCoCo registers standard JVM Shutdown hook - see >> http://docs.oracle.com/javase/7/docs/api/java/lang/Runtime.html#addShutdownHook(java.lang.Thread) >> For execution of shutdown hooks *JVM must be terminated gracefully, i.e. >> not killed*. >> >> Regards, >> Evgeny >> >> On Monday, August 10, 2020 at 6:14:03 PM UTC+3 Jennie wrote: >> >>> Hello, >>> >>> I have been using Jacoco for code coverage for both unit and integration >>> test in the past. My env for integration test by then is pure docker image >>> and it has been working great (using both tcpclient and destfile >>> approaches). However, I encountered problems when I switched to kubernetes >>> env, there, with tcpclient jvm option, I observed that .exec file (zero >>> size) was created during the pod startup, then I ran the test, after that I >>> used kubectl scale to shutdown the pod/container, .exec data wasn't flushed >>> (from ExecutionDataServer), I also tried to kubectl exec to the container >>> and issued kill command there to terminate the container's jvm, still no >>> .exec flushed. One thing I noticed is that with docker env, >>> visitSessionInfo method was called before flushing the data, however, this >>> method was never get called for a container in a kubernetes env. >>> >>> I'm not sure what additional info you prefer me to provide as this time, >>> but I would happy to provide any info needed in order to investigate. >>> >>> Thanks! >>> >>> -- You received this message because you are subscribed to the Google Groups "JaCoCo and EclEmma Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jacoco+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jacoco/064e19b0-884d-41f0-9be6-db78762f29e4n%40googlegroups.com.