Description
I am not sure whether to file the issue here or to Spring Cloud Config directly because I don't know at which part the issue occurs.
I want to port an application to Spring Boot Native with Spring Cloud Config. We followed the documentation of
Spring Boot Native here: https://docs.spring.io/spring-boot/reference/packaging/native-image/index.html and
Spring Cloud Config Native here: https://docs.spring.io/spring-cloud-config/docs/current/reference/html/#_aot_and_native_image_support_2
I created a repository to demonstrate the issue: https://github.com/klopfdreh/native-cloud-config-test and provided 9 steps in the README.md to reproduce it.
Short summary: Spring AOT processes the application with the profile native_runtime
which the running application logs as active on startup. From the config server how ever the definition of the profile is not fetched - only default
.
What we wanted is that the native image is running with no profile active and only the default
configuration is used.
The logging that a profile is active and not fetched from the config server is somehow confusing.
Comparison:
Java Application with native_runtime
profile activated:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.3.1)
2024-07-19T13:48:10.853+02:00 INFO 8811 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : Starting ConfigClientApplication using Java 18.0.1 with PID 8811 (/Users/klopfdreh/Documents/Projects/native-cloud-config-test/client/target/classes started by klopfdreh in /Users/klopfdreh/Documents/Projects/native-cloud-config-test)
2024-07-19T13:48:10.855+02:00 INFO 8811 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : The following 1 profile is active: "native_runtime"
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://127.0.0.1:8888
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=application, profiles=[default], label=null, version=null, state=null
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://127.0.0.1:8888
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=Config Client Application, profiles=[native_runtime], label=null, version=null, state=null
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://127.0.0.1:8888
2024-07-19T13:48:10.871+02:00 INFO 8811 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=Config Client Application, profiles=[default], label=null, version=null, state=null
2024-07-19T13:48:11.043+02:00 INFO 8811 --- [Config Client Application] [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
Native Application:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.3.1)
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : Starting AOT-processed ConfigClientApplication using Java 17.0.10 with PID 1 (/native-image/config-client-application started by ? in /native-image-build)
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : The following 1 profile is active: "native_runtime"
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://host.docker.internal:8888
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=application, profiles=[default], label=null, version=null, state=null
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://host.docker.internal:8888
2024-07-19T11:22:17.919Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=Config Client Application, profiles=[default], label=null, version=null, state=null
2024-07-19T11:22:17.931Z INFO 1 --- [Config Client Application] [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-07-19T11:22:17.932Z INFO 1 --- [Config Client Application] [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.5.2.Final
2024-07-19T11:22:17.933Z INFO 1 --- [Config Client Application] [ main] o.h.c.internal.RegionFactoryInitiator : HHH000026: Second-level cache disabled
Native Application with env var SPRING_PROFILES_ACTIVE=native_runtime
activated:
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.3.1)
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : Starting AOT-processed ConfigClientApplication using Java 17.0.10 with PID 1 (/native-image/config-client-application started by ? in /native-image-build)
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] n.c.c.t.client.ConfigClientApplication : The following 1 profile is active: "native_runtime"
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://host.docker.internal:8888
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=application, profiles=[default], label=null, version=null, state=null
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://host.docker.internal:8888
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=Config Client Application, profiles=[native_runtime], label=null, version=null, state=null
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Fetching config from server at : http://host.docker.internal:8888
2024-07-19T11:54:13.945Z INFO 1 --- [Config Client Application] [ main] o.s.c.c.c.ConfigServerConfigDataLoader : Located environment: name=Config Client Application, profiles=[default], label=null, version=null, state=null
2024-07-19T11:54:13.970Z INFO 1 --- [Config Client Application] [ main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2024-07-19T11:54:13.974Z INFO 1 --- [Config Client Application] [ main] org.hibernate.Version : HHH000412: Hibernate ORM core version 6.5.2.Final
2024-07-19T11:54:13.976Z INFO 1 --- [Config Client Application] [ main] o.h.c.internal.RegionFactoryInitiator : HHH000026: Second-level cache disabled