8000 Add JRE dependency to Java components by viren-nadkarni · Pull Request #11462 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

Add JRE dependency to Java components #11462

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

Merged
merged 15 commits into from
Oct 9, 2024
Merged

Add JRE dependency to Java components #11462

merged 15 commits into from
Oct 9, 2024

Conversation

viren-nadkarni
Copy link
Member
@viren-nadkarni viren-nadkarni commented Sep 4, 2024

Background

#11139 introduced a Java LPM package that can install and manage multiple LTS versions of JRE.

This PR integrates this package across the codebase.

Changes

  • The default system-wide JRE that was previously installed during Docker build is removed
  • Instead, each component has an explicit dependency on the Java package, and is responsible for installing the required version. This is done via the newly introduced JavaInstallerMixin class.
  • For OpenSearch/ElasticSearch, the bundled JRE is used

@viren-nadkarni viren-nadkarni self-assigned this Sep 4, 2024
@viren-nadkarni viren-nadkarni added the semver: patch Non-breaking changes which can be included in patch releases label Sep 4, 2024
@viren-nadkarni viren-nadkarni changed the title Add Java package dependencies Add Java dependency to LPM packages Sep 4, 2024
@viren-nadkarni viren-nadkarni force-pushed the use-java-package branch 4 times, most recently from ab55914 to 3abf962 Compare September 10, 2024 13:54
Base automatically changed from update-java-21 to master September 12, 2024 11:28
@viren-nadkarni viren-nadkarni changed the title Add Java dependency to LPM packages Add JRE dependency to Java components Sep 12, 2024
Copy link
github-actions bot commented Sep 12, 2024

LocalStack Community integration with Pro

    2 files  ±0      2 suites  ±0   1h 40m 51s ⏱️ +11s
3 487 tests ±0  3 072 ✅ ±0  415 💤 ±0  0 ❌ ±0 
3 489 runs  ±0  3 072 ✅ ±0  417 💤 ±0  0 ❌ ±0 

Results for commit 19b4f38. ± Comparison against base commit eb9600f.

♻️ This comment has been updated with latest results.

@viren-nadkarni viren-nadkarni added this to the 3.8 milestone Sep 23, 2024
@alexrashed alexrashed mentioned this pull request Oct 1, 2024
@viren-nadkarni viren-nadkarni modified the milestones: 3.8, 4.0 Oct 1, 2024
Copy link
Member
@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, thanks so much! This is really a great cleanup with all the packages using Java! 🥳
It now really only is an underlying layer of the actually used packages. As soon as none of the packages are installed by default, the image would become way smaller! And you are also ensuring that every tool is using the exact same version of Java they should use. 💯

I added some suggestions to maybe introduce a bit of a devx improvement when using these packages. And I would suggest to use the default version of Java wherever possible to (a) ease upgrades by having a single value to change and test compatibility, and (b) trying to avoid installing multiple versions of Java whenever possible.

@@ -18,6 +19,8 @@
URL_ASPECTJWEAVER = f"{MAVEN_REPO_URL}/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar"
JAR_URLS = [URL_ASPECTJRT, URL_ASPECTJWEAVER]

SFN_JAVA_VERSION = "11"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for KCL, maybe we could avoid setting the version here completely, because it is compatible with Java 11+?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexrashed By explicitly specifying the required JRE version in each downstream package, we remove the dependency on the value of fallback/default version in java package.

This will ensure that we can change the fallback/default version of java any time, without breaking any of the other packages.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly the compromise. Either we can change the default version at any time but it's not really used anywhere (because it's explicitly set everywhere). Or we don't set the version wherever it's not explicitly necessary and we can change it in one place to test the upgrade of the default version everywhere with a minimal change.

This is why I would be in favor of only defining a Java version if we know it won't be compatible with Java 11+.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I'm fully convinced, but I've removed the pins in c9faf3d. We can revisit this at a later point if need arises.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should come to an agreement though. Could you please elaborate why you are not convinced? I think we should discuss this and come to a unanimous conclusion for this kind of pattern as it's quite fundamental and would pave the way how we are going to handle this case in the future.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see these packages not differently from any Linux packaging system. These often have have 'default' version (eg. there might be pre-release versions or older versions of the same application). Yet, downstream packages have exact pinning on its dependency.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's an interesting analogy, but I would compare it more with our approach on any other dependency, i.e. our Python dependencies.

We don't really want to pin explicit dependencies, because it would make it harder for us to easily upgrade them. We only limit the range for dependencies where we know that there are incompatibilities. At the same time we do pin an exact version and once a week we run our action to update all lock files, creating a PR where we test the upgrade. If it works, it's great. If not, we can introduce certain version range limits or even exact pins.

For me the current approach here is the same. We don't pin the version in the specific installers (at least in those where we don't know about limitations). But we have the default version set (this would be the version lock in our analogy). We could then create a single PR to update the "lock" / default version and test if the integration works well. If it doesn't work, we can limit the version in certain installers or even move away from the upgrade completely.

In the future, I would also love to see an iteration on the package installer framework to (among other things) implement an automated process to suggest version bumps for package installers.

@viren-nadkarni viren-nadkarni marked this pull request as draft October 4, 2024 08:26
@viren-nadkarni viren-nadkarni marked this pull request as ready for review October 7, 2024 08:04
@viren-nadkarni viren-nadkarni requested review from alexrashed and removed request for joe4dev, dominikschubert and gregfurman October 7, 2024 08:04
@alexrashed alexrashed added semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases and removed semver: patch Non-breaking changes which can be included in patch releases labels Oct 7, 2024
@localstack-bot
Copy link
Collaborator

Currently, only patch changes are allowed on master. Your PR labels (semver: minor) indicate that it cannot be merged into the master at this time.

Copy link
Member
@alexrashed alexrashed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all the comments! I think the new mixin looks pretty nice, and this PR generally cleans up a lot around the Java installers! 🏅

@viren-nadkarni viren-nadkarni merged commit de27208 into master Oct 9, 2024
34 of 35 checks passed
@viren-nadkarni viren-nadkarni deleted the use-java-package branch October 9, 2024 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver: minor Non-breaking changes which can be included in minor releases, but not in patch releases
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0