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

MP-Configuration: Environment variables not resolved in prod mode #4123

Closed
HeavyTobi opened this issue Sep 20, 2019 · 9 comments
Closed

MP-Configuration: Environment variables not resolved in prod mode #4123

HeavyTobi opened this issue Sep 20, 2019 · 9 comments
Labels
Milestone

Comments

@HeavyTobi
Copy link

HeavyTobi commented Sep 20, 2019

Describe the bug
I am trying to configure the REST client base url using the application.properties, which is working

Expected behavior
If no environment variable called SERVICE_URL is set, a default value should be used as URL, if it is set, it should use the env variable.

Actual behavior
the application is not even resolving the expression in the application.properties file when using the jar file generated with the quarkusBuild task. But works fine in QuarkusDev.

Same issue when using Windows and Linux

To Reproduce
Steps to reproduce the behavior:

  1. Create a quarkus project with gradle as build tool
  2. Implement an example REST Client as described on official quarkus docs
  3. in application.properties replace the given url with ${SERVICE_URL;http://example-api.com}
  4. set the environment variable SERVICE_URL using export SERVICE_URL=http://some-other-api.com
  5. Try with quarkusDev and quarkusBuild

Configuration

com.somecompany.test.service.CamundaService/mp-rest/url=${CAMUNDA_URL:http://localhost:6060}
%prod.com.somecompany.test.service.CamundaService/mp-rest/url=${CAMUNDA_URL:http://localhost:6060}

Screenshots
(If applicable, add screenshots to help explain your problem.)

Environment [Windows] (please complete the following information):

  • Output of uname -a or ver: Microsoft Windows [Version 10.0.18362.356]
  • Output of java -version: openjdk version "11" 2018-09-25
  • GraalVM version (if different from Java): not used
  • Quarkus version or git rev: 0.22.0

Environment [WSL] (please complete the following information):

Additional context
using gradle as build tool

@HeavyTobi HeavyTobi added the kind/bug Something isn't working label Sep 20, 2019
@geoand
Copy link
Contributor

geoand commented Sep 20, 2019

I tried the general idea with the a modified version of the application-configuration quickstart (basically setting the value greeting.message to ${ENV_GREETING:hello}) and things worked as expected.
I remember this working because I had added a SO answer about it.

Then I also tried with the REST-Client and indeed I could reproduce the problem you mention.

@geoand
Copy link
Contributor

geoand commented Sep 20, 2019

@dmlloyd I looks like the ExpandingConfigSource is not used at runtime so when an attempt is made to pull a property value from Config, it never gets expanded.
Is there any reason we can't use ExpandingConfigSource for the in-jar properties?

@dmlloyd
Copy link
Member

dmlloyd commented Sep 20, 2019

@dmlloyd I looks like the ExpandingConfigSource is not used at runtime so when an attempt is made to pull a property value from Config, it never gets expanded.

If not it's a bug. We definitely should be adding the expander to all config sources.

That said it might not be worth fixing right now because (apart from the config work I'm already doing which would definitely conflict) I expect MP-config and thus SmallRye Config to formally support property expansion sometime in the next few weeks.

@geoand
Copy link
Contributor

geoand commented Sep 20, 2019

Nice! I think then it makes sense to wait.

@HeavyTobi
Copy link
Author

I can't wait because of an important project. I need at least a workaround. I tried to place an application.properties in the config directory under the workdir but it is not working also. Any alternatives?

@geoand
Copy link
Contributor

geoand commented Sep 23, 2019

You can place application.properties in a directory named config which resides in the directory where you launch the process. Would that cover your needs temporarily?

@HeavyTobi
Copy link
Author

@geoand I already tried that... sadly doesn't work..

@geoand
Copy link
Contributor

geoand commented Sep 23, 2019

@HeavyTobi doesn't work how? I have done that multiple times and it does work:

For example if I have:

/deployments/some-app.jar
/deployments/config/application.properties

and I launch the application from inside /deployments like so:

java -jar some-app.jar

then the (runtime) properties defined in config/application.properties will override the values of the application.properties file that is included inside the jar.

@kenfinnigan
Copy link
Member

Can you try with 0.27, as there was an issue where Rest Client properties weren't respecting the config profiles, which is now resolved

@gsmet gsmet added this to the 1.1.0 milestone Nov 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants