quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.85k stars 2.7k forks source link

Management interface - URLs are resolved at build time with runtime config #44644

Open gsmet opened 3 days ago

gsmet commented 3 days ago

NonApplicationRootPathBuildItem#getManagementUrlPrefix() resolves non-application URLs using runtime config.

While it's not that big of a deal when the result of this call is used in dev mode, it becomes a problem when some of these paths (well, they are actually URLs when the management interface is enabled) are used at runtime such as when the Health UI is made available at runtime.

I think we should avoid using the host when configuring the Health UI as there's a good chance you won't use the interface address to get access to it. I will try to address that in a PR. But that doesn't solve the more general problem we have here.

Noticed while trying to fix NonApplicationRootPathBuildItem#getManagementUrlPrefix() and getting NonApplicationRootPathBuildItemTest to fail.

It can be very easily reproducer with the following project:

management-url-issue.zip

Then:

mvn clean package
java -Dquarkus.management.port=9008 -jar target/quarkus-app/quarkus-run.jar

Go to http://localhost:9008/q/health-ui/ , you will see the following error:

Error while fetching data from [http://0.0.0.0:9000/q/health]

because the config used the URL generated at build time with some default config.

quarkus-bot[bot] commented 3 days ago

/cc @radcortez (config)

gsmet commented 3 days ago

/cc @cescoffier

gsmet commented 3 days ago

FWIW, I fixed the Health UI issue in https://github.com/quarkusio/quarkus/pull/44647 but that doesn't solve the fact that we are building URLs at build time with runtime elements.

cescoffier commented 1 day ago

Yes, all this part should be moved to runtime.

@phillip-kruger when is the 404 page generated?

phillip-kruger commented 23 hours ago

It's generated at build. But I think I should be able to fix this. I'll have a look in the morning.

phillip-kruger commented 6 hours ago

Ok, after looking at this in detail, I realized I might not be the right person to look at this. The dev mode works fine (I thought the error was there). I am not sure how the 404 works in Prod mode. The 404 page and related code is only in dev mode.

cescoffier commented 2 hours ago

@phillip-kruger, we won't change this in prod mode. However, in dev mode, instead of computing the URLs are build time, we would compute them at runtime.

phillip-kruger commented 2 hours ago

It works fine in Dev mode