-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 native ignores 'quarkus.profile' override in native mode #45622
Comments
It is not about profile optimizations. There is no reliable way to change the profile used to build the native image at runtime. This is also not a Quarkus limitation (if we can call it that way). The native image build executes the static blocks during compilation, meaning that any configuration required / used in static blocks (and dependent code), would use the configuration and profile set at build time. You can change the runtime profile, but all those pieces have already been initialized with a different profile, hence the warning. |
Hi @radcortez, It would be cool to mention it explicitly in the docs. Right now it's possible to override and even explained how. But it won't work properly. I spent quite some time debugging =\ Maybe the warning in the doc will help others. P.S. is there any option for compiler to allow dynamid configs? We have a CD pipeline and building each service for each commit twice is quite slow and expensive. |
Yes, but there is no good way to know which configuration is used in the static code. For instance, REST Providers are created statically, so they use the available configuration from the native image build. After the build and when the native image starts, these providers are already initialized, and any configuration changes has no effect.
Actually,
We can add such a warning. Would you like to contribute to it? :)
No, because this really depends on how the code is written: static {
SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class)
config.getValue("foo.bar", String.class);
// do some work
} This block is executed during the native image build, so any configuration used there will have no effect during runtime. |
Hi @radcortez,
You are right! I found a mistake in my setup.
Yes I can do. I didn't contribute to quarkus so far though, so will need some time to ramp up. Hopefully will find this weekend. If you have a link/wiki handy I'd appreciate. Otherwise no worriess I'll try to find. |
Excellent!
A documentation change is pretty straightforward:
Thank you! |
Describe the bug
Hello,
I'm using quakus native (GraalVM) with AWS lambdas. I have BETA/PROD stages where I want to deploy the same build artifact with different runtime configuration from profile files. But Quarkus native ignores config keys for beta after
QUARKUS_PROFILE=beta
env variable override in native mode.Build process takes time, so I want to re-use the same build artifact for both enviroments. Also it is kind of safer to deploy the same binaries that were tested, not generated differently.
Is there a way to achieve my setup? Maybe some GraalVM options to disable profile optimisztions. If no it would be nice to add or at least mention in the docs explicitly. I'd imagine it's quite a common setup so can be useful for others.
Expected behavior
QUARKUS_PROFILE=beta
should override profile for native images and load corresponding configuration (beta in this case at runtime. Or at least tell explicitly that it's not possible.Actual behavior
QUARKUS_PROFILE=beta
. Profile changed with a warning to beta with below warningHow to Reproduce?
application-prod.configuration
,application-beta.configuration
. Also some "common/default" values inapplication.config
. The files are in resources.Output of
uname -a
orver
Version info: 'GraalVM 22.3.0.1-Final Java 17 Mandrel Distribution'
Java version info: '17.0.5+8'
C compiler: gcc (redhat, x86_64, 8.5.0)
Garbage collector: Serial GC
2 user-specific feature(s)
Output of
java -version
Java version info: '17.0.5+8'
Quarkus version or git rev
3.15.1 (LTS)
Build tool (ie. output of
mvnw --version
orgradlew --version
)mvn --version
Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546)
Additional information
No response
The text was updated successfully, but these errors were encountered: