Unable to override config properties for Isolates running in native mode
See original GitHub issueDescribe the bug
The code, that relies on Isolates running in Native image is unable to catch overridden config properties (either passed as command line arguments when launching native executable or overriding properties with QuarkusTestResourceLifecycleManager
in Native tests).
It seems Isolates use the values of properties that are effective at image build time and do not override them in runtime.
Expected behavior Isolates use the values of properties that are effective at runtime (as Native-image code without isolates does).
Actual behavior Isolates use the values of properties that are effective at build time and do not override at runtime.
To Reproduce
public int readPropertyValue() {
var params = CreateIsolateParameters.getDefault();
var isolateThread = Isolates.createIsolate(params);
try {
return processInIsolate(isolateThread);
}
finally {
Isolates.tearDownIsolate(isolateThread);
}
}
@CEntryPoint
private static int processInIsolate(@CEntryPoint.IsolateThreadContext IsolateThread isolateThread) {
int propertyToOverride = ConfigProvider.getConfig().getValue("property.to.override", Integer.class);
System.out.println("property.to.override: " + propertyToOverride);
return propertyToOverride;
}
Demo app, reproducing the bug
Steps to reproduce the behavior:
- run
./gradlew testNative
for demo app
Configuration
# Add your application.properties here, if applicable.
quarkus:
package:
type: native
native:
native-image-xmx: 12g
property:
to:
override: 0
Screenshots (If applicable, add screenshots to help explain your problem.)
Environment (please complete the following information):
- Output of
uname -a
orver
: Darwin MacBook-Pro.local 20.2.0 Darwin Kernel Version 20.2.0: Wed Dec 2 20:39:59 PST 2020; root:xnu-7195.60.75~1/RELEASE_X86_64 x86_64 - Output of
java -version
: - GraalVM version (if different from Java): 20.2.0.r11-grl
- Quarkus version or git rev: 1.10.5.Final
- Build tool (ie. output of
mvnw --version
orgradlew --version
): gradle 6.5.1
Additional context (Add any other context about the problem here.)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9 (7 by maintainers)
@Karm @AndreiYu this is a GraalVM issue, I opened https://github.com/oracle/graal/issues/4238 to track it.
We made a workaround - CustomRuntimeConfigSource that has higher ordinal than System properties and Environment Variables
https://quarkus.io/guides/config-extending-support#example
Isolates are unable to see changes of system properties (since they have a snapshot of Image Heap at build or start time of native executable), but isolate refreshes env_variable changes with CustomRuntimeConfigSource with ordinal 500 and evaluates them at change. Here is a snippet of code:
@StaticInitSafe public class RuntimeEnvConfigSource implements ConfigSource {
}