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

Initialization Tasks failing #41113

Closed
frootshoot opened this issue Jun 11, 2024 · 6 comments · Fixed by #41117
Closed

Initialization Tasks failing #41113

frootshoot opened this issue Jun 11, 2024 · 6 comments · Fixed by #41117
Labels
area/kubernetes kind/bug Something isn't working
Milestone

Comments

@frootshoot
Copy link

Describe the bug

We have been using Liquibase with Kubernetes where in our own helm charts we are configuring a job to run with "QUARKUS_INIT_AND_EXIT" to execute the schema migration.

This was working up to version 3.8.x, and now fails with newer versions due to a NullPointerException on startup - this stops the deployment progressing.

2024-06-11 11:57:55,590 ERROR [io.qua.run.shu.ShutdownRecorder] (Quarkus Main Thread) Graceful shutdown failed: java.lang.NullPointerException: Cannot invoke "java.util.List.size()" because "io.quarkus.runtime.shutdown.ShutdownRecorder.shutdownListeners" is null
	at io.quarkus.runtime.shutdown.ShutdownRecorder.executePreShutdown(ShutdownRecorder.java:42)
	at io.quarkus.runtime.shutdown.ShutdownRecorder.runShutdown(ShutdownRecorder.java:33)
	at io.quarkus.runtime.Application.stop(Application.java:207)
	at io.quarkus.runtime.Application.stop(Application.java:155)
	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:211)
	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)

Following an investigation, it appears that the graceful shutdown code was refactored after 3.8.x which removed the null check for shutdown listeners - however it appears any shutdown listeners are not actually injected until after the point when "init and exit" has finished, leading to the NPE.

Expected behavior

The Quarkus container should run the Liquibase migration and then exit cleanly.

Actual behavior

The Liquibase migration happens as expected but the contianer does not shutdown without the error - stopping the appplication containers from starting.

How to Reproduce?

Running any Quarkus application with environment variable "QUARKUS_INIT_AND_EXIT" set to true.

Output of uname -a or ver

No response

Output of java -version

No response

Quarkus version or git rev

3.11.1

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

No response

@frootshoot frootshoot added the kind/bug Something isn't working label Jun 11, 2024
Copy link

quarkus-bot bot commented Jun 11, 2024

/cc @geoand (kubernetes), @iocanel (kubernetes)

@geoand
Copy link
Contributor

geoand commented Jun 11, 2024

Thanks for reporting!

As you've already investigated this, would you like to contribute a fix?

@frootshoot
Copy link
Author

I am not sure of the intention of the refactor, as it clearly removed the null check - i.e. if the shutdown listeners are supposed to be injected by this point?

@geoand
Copy link
Contributor

geoand commented Jun 11, 2024

What likely happened is that when things were refactored, this use case was not taken into account

@frootshoot
Copy link
Author

As you've already investigated this, would you like to contribute a fix?

I am currently not in a position to contribute code, but happy to help where I can with this.

@geoand
Copy link
Contributor

geoand commented Jun 11, 2024

No problem!

#41117 is the fix

gsmet added a commit that referenced this issue Jun 11, 2024
Fix NPE when `QUARKUS_INIT_AND_EXIT` is used
@quarkus-bot quarkus-bot bot added this to the 3.12 - main milestone Jun 11, 2024
@gsmet gsmet modified the milestones: 3.12 - main, 3.11.2 Jun 11, 2024
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jun 11, 2024
holly-cummins pushed a commit to holly-cummins/quarkus that referenced this issue Jul 31, 2024
danielsoro pushed a commit to danielsoro/quarkus that referenced this issue Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/kubernetes kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants