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

@EndpointDisabled does not work ok with native builds #34738

Open
manofthepeace opened this issue Jul 13, 2023 · 7 comments
Open

@EndpointDisabled does not work ok with native builds #34738

manofthepeace opened this issue Jul 13, 2023 · 7 comments
Labels
area/rest kind/bug Something isn't working

Comments

@manofthepeace
Copy link
Contributor

manofthepeace commented Jul 13, 2023

Describe the bug

When using @EndpointDisabled with a value of false, then we build the native app. It is impossible to set it to true at runtime. It does work with the jar version

Expected behavior

EndpointDisabled should read the config value at used at runtime when using a native build

Actual behavior

EndpointDisabled uses the build time value only.

How to Reproduce?

Reproducer: https://github.com/manofthepeace/quarkus-endpointdisabled-issue

The application has the following;
hello.enabled=false in the application.properties
@EndpointDisabled(name = "hello.enabled", stringValue = "false", disableIfMissing = true) on GreetingResource

Steps to reproduce (doing the same steps with the jar will all work OK)
1- Create a native build
2- run it this way ./target/endpoint-disabled-issue-1.0.0-SNAPSHOT-runner;
3-curl -vv http://localhost:8080/hello ## this returns a 404 and it is ok as the endpoint is disabled by default
4- run this way; HELLO_ENABLED=true ./target/endpoint-disabled-issue-1.0.0-SNAPSHOT-runner
5-curl -vv http://localhost:8080/hello ## this returns a 404 and it is not ok as the endpoint should be enabled

Output of uname -a or ver

Darwin Kernel Version 21.6.0

Output of java -version

OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7)

GraalVM version (if different from Java)

graalvm-jdk-17

Quarkus version or git rev

3.2.0

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

maven 3.9.1

Additional information

No response

@gsmet
Copy link
Member

gsmet commented Jul 20, 2023

@geoand the Javadoc is saying that it actually allows to disable endpoints at runtime but from what I can see, the recorder we are using in setupEndpoints is STATIC_INIT so I wouldn't expect it to work.

@manofthepeace
Copy link
Contributor Author

It seems to work ok native when you go from enabled --> disabled, but not the other way around. Both ways work when not native.

@manofthepeace
Copy link
Contributor Author

I would like to help here, but I would need some pointers on how this can work. setIsDisabledCreator is called in a STATIC_INIT and never runs on runtime on a native build. I cannot see how to make that portion a runtime_init. Is it possible to make it work native?

Otherwise I think it will have to be part of the javadoc + documentation that this feature only works on non-native build, otherwise is is buildTime fixed, and at this point equivalent to IfBuildProperty

@geoand
Copy link
Contributor

geoand commented Nov 6, 2023

We should make it work in native mode as well

@gsmet
Copy link
Member

gsmet commented Nov 13, 2023

From what I can see, the issue is that the disabled status is resolved in RuntimeDeploymentManager#deploy() which is called at static init. So it's runtime for JVM but build time for native, which explains the difference.

@geoand I'm not entirely sure how to fix this as I'm pretty sure we don't want to simply make the deployment runtime.

@geoand
Copy link
Contributor

geoand commented Nov 13, 2023

@geoand I'm not entirely sure how to fix this as I'm pretty sure we don't want to simply make the deployment runtime.

Yeah, that's completely true

@geoand
Copy link
Contributor

geoand commented Nov 21, 2023

I merged the docs updae PR as for the time being I am unsure how to handle this...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest kind/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants