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 ignores all "quarkus.*" environment properties on Kubernetes #36359

Closed
fedinskiy opened this issue Oct 9, 2023 · 16 comments
Closed

Quarkus ignores all "quarkus.*" environment properties on Kubernetes #36359

fedinskiy opened this issue Oct 9, 2023 · 16 comments
Labels
Milestone

Comments

@fedinskiy
Copy link
Contributor

Describe the bug

I have an application, which uses consul, I use property "quarkus.consul-config.agent.host-port" to provide the application with path to deployed consul instance. Starting from 6 or 7 of October, when I deploy this app on Openshift using 999-SNAPSHOT build, the app can not retrieve this property and fails to start.
The property is stored in openshift DeploymentConfig as "template.spec.containers.env.name".
If the property is put into property file, or the property variable inside the yaml is renamed into "QUARKUS_CONSUL_CONFIG_AGENT_HOST_PORT", then everything works fine.

Expected behavior

Application starts succefully

Actual behavior

Application fails with the following error:

16:07:48,407 INFO  [app] java.lang.RuntimeException: Failed to start quarkus
16:07:48,408 INFO  [app] 	at io.quarkus.runner.ApplicationImpl.doStart(Unknown Source)
16:07:48,408 INFO  [app] 	at io.quarkus.runtime.Application.start(Application.java:101)
16:07:48,409 INFO  [app] 	at io.quarkus.runtime.ApplicationLifecycleManager.run(ApplicationLifecycleManager.java:111)
16:07:48,409 INFO  [app] 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:71)
16:07:48,409 INFO  [app] 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:44)
16:07:48,410 INFO  [app] 	at io.quarkus.runtime.Quarkus.run(Quarkus.java:124)
16:07:48,410 INFO  [app] 	at io.quarkus.runner.GeneratedMain.main(Unknown Source)
16:07:48,411 INFO  [app] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
16:07:48,411 INFO  [app] 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
16:07:48,411 INFO  [app] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
16:07:48,412 INFO  [app] 	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
16:07:48,412 INFO  [app] 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.doRun(QuarkusEntryPoint.java:61)
16:07:48,413 INFO  [app] 	at io.quarkus.bootstrap.runner.QuarkusEntryPoint.main(QuarkusEntryPoint.java:32)
16:07:48,413 INFO  [app] Caused by: java.lang.RuntimeException: An error occurred while attempting to fetch configuration from Consul.
16:07:48,413 INFO  [app] 	at io.quarkus.consul.config.runtime.ConsulConfigSourceFactory.getConfigSources(ConsulConfigSourceFactory.java:82)
16:07:48,414 INFO  [app] 	at io.quarkus.consul.config.runtime.ConsulConfigSourceFactory.getConfigSources(ConsulConfigSourceFactory.java:28)
16:07:48,414 INFO  [app] 	at io.quarkus.consul.config.runtime.ConsulConfigSourceFactory.getConfigSources(ConsulConfigSourceFactory.java:19)
16:07:48,415 INFO  [app] 	at io.smallrye.config.ConfigSourceFactory$ConfigurableConfigSourceFactory.getConfigSources(ConfigSourceFactory.java:58)
16:07:48,415 INFO  [app] 	at io.smallrye.config.ConfigurableConfigSource.getConfigSources(ConfigurableConfigSource.java:50)
16:07:48,416 INFO  [app] 	at io.smallrye.config.SmallRyeConfig$ConfigSources.mapLateSources(SmallRyeConfig.java:687)
16:07:48,416 INFO  [app] 	at io.smallrye.config.SmallRyeConfig$ConfigSources.<init>(SmallRyeConfig.java:577)
16:07:48,416 INFO  [app] 	at io.smallrye.config.SmallRyeConfig.<init>(SmallRyeConfig.java:68)
16:07:48,417 INFO  [app] 	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:698)
16:07:48,417 INFO  [app] 	at io.quarkus.runtime.generated.Config.readConfig(Unknown Source)
16:07:48,417 INFO  [app] 	at io.quarkus.runtime.generated.Config.createRunTimeConfig(Unknown Source)
16:07:48,418 INFO  [app] 	at io.quarkus.deployment.steps.RuntimeConfigSetup.deploy(Unknown Source)
16:07:48,418 INFO  [app] 	... 13 more
16:07:48,419 INFO  [app] Caused by: java.util.concurrent.CompletionException: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:8500
16:07:48,419 INFO  [app] 	at io.smallrye.mutiny.operators.uni.UniBlockingAwait.await(UniBlockingAwait.java:79)
16:07:48,420 INFO  [app] 	at io.smallrye.mutiny.groups.UniAwait.atMost(UniAwait.java:65)
16:07:48,420 INFO  [app] 	at io.quarkus.consul.config.runtime.ConsulConfigSourceFactory.getConfigSources(ConsulConfigSourceFactory.java:79)
16:07:48,420 INFO  [app] 	... 24 more
16:07:48,421 INFO  [app] Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: localhost/127.0.0.1:8500
16:07:48,422 INFO  [app] Caused by: java.net.ConnectException: Connection refused
16:07:48,422 INFO  [app] 	at java.base/sun.nio.ch.Net.pollConnect(Native Method)
16:07:48,422 INFO  [app] 	at java.base/sun.nio.ch.Net.pollConnectNow(Net.java:672)
16:07:48,423 INFO  [app] 	at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:946)
16:07:48,423 INFO  [app] 	at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:337)
16:07:48,424 INFO  [app] 	at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
16:07:48,424 INFO  [app] 	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:776)
16:07:48,425 INFO  [app] 	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724)
16:07:48,425 INFO  [app] 	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650)
16:07:48,425 INFO  [app] 	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562)
16:07:48,426 INFO  [app] 	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
16:07:48,426 INFO  [app] 	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
16:07:48,427 INFO  [app] 	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
16:07:48,427 INFO  [app] 	at java.base/java.lang.Thread.run(Thread.java:833)

How to Reproduce?

  1. git clone [email protected]:quarkus-qe/quarkus-test-framework.git
  2. mvn clean install -Pframework
  3. Log in into openshift
    This fails: " mvn clean install -Pexamples,openshift -pl examples/consul/ -Dit.test=OpenShiftGreetingResourceIT -Dquarkus.platform.version=999-SNAPSHOT"
    This works as expected: mvn clean install -Pexamples,openshift -pl examples/consul/ -Dit.test=OpenShiftGreetingResourceIT -Dquarkus.platform.version=3.4.2

If option -Dts.global.delete.folder.on.exit=false is added, then yaml file examples/consul/target/OpenShiftGreetingResourceIT/app/openshift.yml contains deployment config
By default, the project is cleared afterwards, add -Dts.openshift.delete.project.after.all=false -Dts.openshift.ephemeral.namespaces.enabled=false to use the persistent one

Output of uname -a or ver

6.4.14-200.fc38.x86_64

Output of java -version

17.0.5, vendor: GraalVM Community

GraalVM version (if different from Java)

No response

Quarkus version or git rev

6be99a4

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

Apache Maven 3.8.7 (b89d5959fcde851dcb1c8946a785a163f14e1e29)

Additional information

No response

@fedinskiy fedinskiy added the kind/bug Something isn't working label Oct 9, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Oct 9, 2023

/cc @geoand (kubernetes,openshift), @iocanel (kubernetes,openshift)

@fedinskiy
Copy link
Contributor Author

Probably also area/config

@fedinskiy
Copy link
Contributor Author

Commit 39381f9 is not affected, so I presume this is caused by #35322

@geoand
Copy link
Contributor

geoand commented Oct 9, 2023

cc @radcortez

@radcortez
Copy link
Member

I'll have a look.

@fedinskiy
Copy link
Contributor Author

Addition: this affect all "quarkus.*" properties, not just "consul-config.agent.host-port"

@fedinskiy fedinskiy changed the title Quarkus ignores environment property "consul-config.agent.host-port" on Kubernetes Quarkus ignores all "quarkus.*" environment properties on Kubernetes Oct 10, 2023
@radcortez
Copy link
Member

I have an application, which uses consul, I use property "quarkus.consul-config.agent.host-port" to provide the application with path to deployed consul instance. Starting from 6 or 7 of October, when I deploy this app on Openshift using 999-SNAPSHOT build, the app can not retrieve this property and fails to start.

Are you using precisely this property name? quarkus.consul-config.agent.host-port, or is it the environment variable name?

The property is stored in openshift DeploymentConfig as "template.spec.containers.env.name".

Are you setting environment variable names in dotted format?

If the property is put into property file, or the property variable inside the yaml is renamed into "QUARKUS_CONSUL_CONFIG_AGENT_HOST_PORT", then everything works fine.

From the last comment, I'm guessing that you are using quarkus.consul-config.agent.host-port in a source that should only take Environment Variables as QUARKUS_CONSUL_CONFIG_AGENT_HOST_PORT. It may have worked in the past, but this was never intended to work...

@fedinskiy
Copy link
Contributor Author

@radcortez yes, the app uses environment variables in dotted format and for some reason this worked (presumably for a long time).
I agree, that this is strange, but we should probably document, that it doesn't work anymore.

@radcortez
Copy link
Member

Sure. Feel free to document it. Thanks!

@fedinskiy
Copy link
Contributor Author

That should go to release notes I suppose. Who is handling that for Quarkus and how do I contact that person?

fedinskiy added a commit to fedinskiy/quarkus-test-framework that referenced this issue Oct 12, 2023
Before that change we used quarkus CLI properties as environment
variables in openshift manifests (which we should not have do) and
for some reason it worked (which it should not have do).
When this behaviour was changed upstream, our jobs started to fail,
this change should fix that.

See quarkusio/quarkus#36359 for details
@radcortez
Copy link
Member

Release notes are added here:
https://github.com/quarkusio/quarkus/wiki/Migration-Guide-3.5

Are you able to edit and add the notes in the Config section?

fedinskiy added a commit to fedinskiy/quarkus-test-framework that referenced this issue Oct 12, 2023
Before that change we used quarkus CLI properties as environment
variables in openshift manifests (which we should not have do) and
for some reason it worked (which it should not have do).
When this behaviour was changed upstream, our jobs started to fail,
this change should fix that.

See quarkusio/quarkus#36359 for details
@fedinskiy
Copy link
Contributor Author

No, I can not.

I prepared a note, could you add it into the guide?

System properties can not be used as environmental variables anymore.

For some time, it was possible to have quarkus environment variables in dotted.lower-case (style, used for system properties) and such variables were read and accepted by Quarkus. This was accidental and against specifications[1], and was removed in this release. From now on, Quarkus accepts environment variables only in SCREAMING_SNAKE_CASE.

[1] https://quarkus.io/guides/config-reference#system-properties

@janderssonse
Copy link
Contributor

janderssonse commented Nov 11, 2023

This helped me, we have quite a few config envs in the x.y.z-format to change to X_Y_Z now. While the release notes makes it quite clear, @radcortez @fedinskiy last note should really be a added to the https://quarkus.io/guides/config-reference#environment-variables documentation paragraph, as it stil gives examples of envrionment naming resolutions in x.Y.Z-formats. And so, people that didn't read every release note will contiinue trying that format. @radcortez Should I open a seperate issue regadring environment documentation?

@radcortez
Copy link
Member

This helped me, we have tons of config envs in the x.y.z-format to change to X_Y_Z now.

You may want to hold that change :)

I was not aware that so many users were relying on this, so I reaaded the support in #36917.

@janderssonse
Copy link
Contributor

janderssonse commented Nov 11, 2023

Thanks @radcortez , I have now read the thread at #36917 , and that docker handling with dot mixed upper/lower case mode was surely interesting, I can see why you would want to add the dot-support /mixedmode:) We already started the posix compatible journey as we are deploying that version atm, (no big issue for us)

@radcortez
Copy link
Member

Great :)

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

4 participants