-
Notifications
You must be signed in to change notification settings - Fork 40.9k
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
Build of OCI image fails with both AOT and CDS when Flyway used #41348
Comments
I have created a repository that demonstrates the problem at https://github.com/nwholloway/spring-boot-demo-41348 The It uses Gradle properties to enable CDS and/or AOT for the build. Enable CDS using With both AOT and CDS, |
Thanks very much for the sample, @nwholloway. You can work around the current limitation using a custom migration strategy: @Bean
FlywayMigrationStrategy flywayMigrationStrategy() {
return (flyway) -> {
String flywayEnabled = System.getProperty("spring.flyway.enabled");
if (flywayEnabled == null || Boolean.valueOf(flywayEnabled)) {
flyway.migrate();
}
};
} With this bean in place, |
Setting Setting When using |
Thank you @wilkinsona for the custom migration strategy, and @scottfrederick for the suggestion of not using AOT during CDS training. I think the |
@sdeleuze Is this scenario something that could be covered in the lifecycle smoke test documentation? |
* it could break apps that had AOT'ed some migration library like flyway during build, which would need some extra code (java) to not automatically use them at runtime (and training run...) see: spring-projects/spring-boot#41348 * after confirmation we won't ever re introduce AOT support along with CDS in Spring Boot buildpack, we'll deprecate the feature
After discussion with @snicoll and the Buildpacks team and as mentioned in the PR linked above, I think the issue raised here is serious and "by design" enough to not promote this AOT Buildpacks flag anymore as for some use cases, it won't work due to conflicts between training run configuration and AOT configuration precomputation. This flag was not really dedicated feature, more a shortcut to add I am not sure we should add for now specific documentation in https://github.com/spring-projects/spring-lifecycle-smoke-tests as this is not a use case fully supported, but we can discuss that if you strongly think we should. @nwholloway Thanks for catching that shortly after our GA. |
For those who would like to explore that route, it does require two rounds of AOT processing unfortunately. I haven't tested it but something like:
There are a lot of gotchas doing this yourself that buildpacks shield you from so definitely more involved. For now, I'd go with only CDS. |
As explained in spring-projectsgh-41348, the BP_SPRING_AOT_ENABLED flag should not be promoted as it can't work by design with our current support when combined with CDS for various use cases and provides little added value as the same behavior can be achieved by adding -Dspring.aot.enabled=true to JAVA_TOOL_OPTIONS and CDS_TRAINING_JAVA_TOOL_OPTIONS.
As explained in gh-41348, the BP_SPRING_AOT_ENABLED flag should not be promoted as it can't work by design with our current support when combined with CDS for various use cases and provides little added value as the same behavior can be achieved by adding -Dspring.aot.enabled=true to JAVA_TOOL_OPTIONS and CDS_TRAINING_JAVA_TOOL_OPTIONS. See gh-41464
…G_AOT_ENABLED=true * those 2 options are not compatible, see spring-projects/spring-boot#41348
Tested with Spring Boot 3.3.1
I was investigating creating an OCI image of a Spring Boot application using both AOT and CDS to create a container with reduced start up time with a JVM, without the additional complexity of building a native image.
This was fine with a do-nothing application using Spring Web, but it fails when you have Flyway as a dependency.
The training run to build the CDS archive does not honour the disabling of Flyway migration (presumably due to being built into the AOT generated classes), so you get the following build error:
It would be good to have the dual benefits of AOT processing and CDS training when building an OCI image.
The text was updated successfully, but these errors were encountered: