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

quarkus.profile is fixed at build time while it is documented as runtime #28176

Closed
rmanibus opened this issue Sep 23, 2022 · 7 comments · Fixed by #28091
Closed

quarkus.profile is fixed at build time while it is documented as runtime #28176

rmanibus opened this issue Sep 23, 2022 · 7 comments · Fixed by #28091
Assignees
Labels
area/config kind/bug Something isn't working
Milestone

Comments

@rmanibus
Copy link
Contributor

rmanibus commented Sep 23, 2022

Describe the bug

quarkus profile cannot be changed at runtime. It always stick to the value configured at build time.
I don't know if this is expected or not,
but in the documentation, it is documented as a runtime value (without the lock).

Also I think it should be a good thing to be able to set the profile at runtime (while I understand this would only affect runtime config values, and the profile used during the build would affect build time values)

Verified on 2.12.3.Final;

@rmanibus rmanibus added the kind/bug Something isn't working label Sep 23, 2022
@mschorsch
Copy link
Contributor

There are two profiles, one used at build time and one used at run time. The profile used at build time is also the profile that is used as the default at runtime if no profile is specified explicitly.

@rmanibus
Copy link
Contributor Author

rmanibus commented Sep 24, 2022

@mschorsch that is what I thought too, but when I start my app with a runtime profile the message in the log is still "quarkus started with profile prod", and I don't think it is a display issue because my custom config in the uat profile is not applied.

@radcortez
Copy link
Member

I've tried a simple project, and it seems to work as expected:

java -Dquarkus.profile=x -jar target/quarkus-app/quarkus-run.jar
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-09-26 18:04:13 INFO  [io.qua.sma.ope.run.OpenApiRecorder]] (main) Default CORS properties will be used, please use 'quarkus.http.cors' properties instead
2022-09-26 18:04:13 INFO  [io.quarkus]] (main) number-api 1.0-SNAPSHOT on JVM (powered by Quarkus 2.12.3.Final) started in 0.979s. Listening on: http://0.0.0.0:8090
2022-09-26 18:04:13 INFO  [io.quarkus]] (main) Profile x activated.

and

java -Dquarkus.profile=y -jar target/quarkus-app/quarkus-run.jar
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2022-09-26 18:04:54 INFO  [io.qua.sma.ope.run.OpenApiRecorder]] (main) Default CORS properties will be used, please use 'quarkus.http.cors' properties instead
2022-09-26 18:04:54 INFO  [io.quarkus]] (main) number-api 1.0-SNAPSHOT on JVM (powered by Quarkus 2.12.3.Final) started in 0.992s. Listening on: http://0.0.0.0:8090
2022-09-26 18:04:54 INFO  [io.quarkus]] (main) Profile y activated.

Are you able to provide additional steps or even a reproducer? Maybe you have your profile in a higher ordinal source?

@radcortez radcortez self-assigned this Sep 26, 2022
@rmanibus
Copy link
Contributor Author

rmanibus commented Sep 26, 2022

@radcortez I set it in the config/application.yml main section, is it mandatory to pass it as property ?

if I try to display quarkus.profile config property by injecting it somewhere, the value is uat as expected, however the startup message is still

"2022-09-26 14:15:35,039 INFO [io.quarkus] (main) Profile prod activated."

@radcortez
Copy link
Member

radcortez commented Sep 26, 2022

Yes, at the moment, quarkus.profile is only read from system properties or environment variables to select the active profile to use. If you do a regular lookup you may get a different value coming from another source.

This should be fixed by #28091. Until then, please set quarkus.profile in system properties or environment variables.

@rmanibus
Copy link
Contributor Author

rmanibus commented Sep 27, 2022

@radcortez thanks a lot, should I close it for now ? Maybe this worth a note in the doc ?

@radcortez
Copy link
Member

You can leave it open so I can make some adjustments to #28091.

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

Successfully merging a pull request may close this issue.

4 participants