5

When setting environment variables for properties with hyphens, such as:

quarkus.datasource.db-kind=postgresql

I would expect it to be set as:

export QUARKUS_DATASOURCE_DB_KIND=postgresql

However, that results in an the following message:

Unrecognized configuration key "quarkus.datasource.db.kind" was provided; it will be ignored;

All other properties, without hyphens, are passed correctly.

It also happens for other properties:

export QUARKUS_DATASOURCE_JDBC_MIN_SIZE=10
export QUARKUS_DATASOURCE_JDBC_INITIAL_SIZE=20
export QUARKUS_DATASOURCE_JDBC_MAX_SIZE=1000
...
Unrecognized configuration key "quarkus.datasource.jdbc.max.size" was provided;
Unrecognized configuration key "quarkus.datasource.jdbc.min.size" was provided;
Unrecognized configuration key "quarkus.datasource.jdbc.initial.size" was provided;

Workaround: Rename the environment variables and pass them into application.properties, with the hyphen names:

quarkus.datasource.jdbc.initial-size=${DATASOURCE_JDBC_INITIAL_SIZE}
quarkus.datasource.jdbc.min-size=${DATASOURCE_JDBC_MIN_SIZE}
quarkus.datasource.jdbc.max-size=${DATASOURCE_JDBC_MAX_SIZE}

What is the proper conversion? Is it documented somewhere?

Julio Faerman
  • 13,228
  • 9
  • 57
  • 75

3 Answers3

2

Quarkus follows the naming conventions from MicroProfile:

Exact match (i.e. com.ACME.size)

Replace each character that is neither alphanumeric nor _ with _ (i.e. com_ACME_size)

Replace each character that is neither alphanumeric nor _ with _; then >convert the name to upper case (i.e. COM_ACME_SIZE)

Thus QUARKUS_DATASOURCE_DB_KIND is correct, but that property is a build time only property as seen with the lock icon on https://quarkus.io/guides/all-config#quarkus-datasource_quarkus.datasource.db-kind

Thus you would need to set this at build time to have effect.

That said, the error message is not great and if you can confirm you are trying to set this a runtime not build time then please open issue with your context and suggest the error message is improved to highlight it is or could be a build time only property.

Max Rydahl Andersen
  • 3,630
  • 2
  • 23
  • 28
  • The property is set for the entire shell, build and runtime... perhaps there a way to check what is the actual runtime value of all config properties... – Julio Faerman Jun 04 '21 at 09:35
  • Setting the initial pool size, max size, min size, initial size also produce the same warning: ``` 2021-09-27 18:16:14,783 WARN [io.qua.config] (main) Unrecognized configuration key "quarkus.datasource.jdbc.min.size" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo ``` The env vars set is: - QUARKUS_DATASOURCE_JDBC_INITIAL_SIZE According to https://quarkus.io/guides/datasource#jdbc-configuration, they can be set at runtime. – thescouser89 Sep 27 '21 at 18:31
1

Try replacing hyphen with underscore. It works in my case despite the warning message.

application.yml

quarkus:
   swagger-ui:
     enable: false

docker run

$ docker run -d -e QUARKUS_SWAGGER_UI_ENABLE=true -p 8080:8080 sample.com/foo
__  ____  __  _____   ___  __ ____  ______
 --/ __ \/ / / / _ | / _ \/ //_/ / / / __/
 -/ /_/ / /_/ / __ |/ , _/ ,< / /_/ /\ \
--\___\_\____/_/ |_/_/|_/_/|_|\____/___/
2021-06-09T05:34:55.192Z WARN  [io.qua.config] Unrecognized configuration key "quarkus.swagger.ui.enable" was provided; it will be ignored; verify that the dependency extension for this configuration is set or that you did not make a typo
2021-06-09T05:35:12.947Z INFO  [sam.com.access-log] 192.168.113.42 - - "GET /q/openapi HTTP/1.1" 200 14464 -
Thanh Nhan
  • 453
  • 6
  • 17
-1

I think most shells consider the hyphen to be an invalid identifier. Depending on how quarkus is run, (CLI?), you can do something like

env "QUARKUS_DATASOURCE_DB-KIND=postgresql" quarkus

This makes some assumptions about how the env variables are converted into configuration keys. Based on the information you provided, it looks like cast to lowercase and replace _ with .? Who knows what it will do to the hyphen

myz540
  • 537
  • 4
  • 7