Skip to content
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

feat(jdk): Add Java 25 preview target for all images #939

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

gounthar
Copy link
Contributor

@gounthar gounthar commented Feb 12, 2025

Introduction

The upcoming release of JDK 25 in October 2025 marks a significant milestone for Java developers, bringing new features and enhancements. Early adoption and testing of JDK 25 are crucial for ensuring compatibility and leveraging its improvements. By starting with Jenkins agent images, we can iterate incrementally, eventually extending support to Jenkins controller images and the broader Jenkins infrastructure.

Why Start with Jenkins Agent Images?

  1. Incremental Testing: Agent images are ideal for early experimentation without disrupting the core Jenkins controller.
  2. Modular Approach: Agents allow isolated testing of pipelines and plugins with JDK 25.
  3. Foundation for Expansion: Success with agents can pave the way for seamless integration into controllers and infrastructure.

These changes introduce support for JDK 25 across multiple build configurations. The Dockerfiles now feature a new conditional branch in the jlink command to apply "--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se" when detecting a JDK version starting with "25." The build configurations and targets have been updated in docker-bake.hcl, along with the necessary updatecli YAML configuration adjustments. Additionally, the Windows Server Core Dockerfile is modified to install and point to JDK 25, while the build script has been reformatted without functional changes.

JDK 25 requires the --module-path option when using ALL-MODULE-PATH. JDK 24 and 25 of Temurin enable JEP 493.

Currently, I've added a minimal set of modules (java.base,java.logging,java.xml,java.se) detected using jdeps -cp "agent.jar:slave.jar" -R --print-module-deps --ignore-missing-deps agent.jar, though this might not suffice in the long run. We will need to add more than just this limited set of modules, but not necessarily all 69 of them.

Keeping the JDK25 version updated

If this PR is merged, I will then supply an updatecli manifest to keep the version updated.

Testing done

make every-build

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira
  • Link to relevant pull requests, esp. upstream and downstream changes
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

Fixes #6

Add Java 25 target for all images in docker bake and other necessary places.

* Modify `docker-bake.hcl` to include Java 25 in various targets and functions.
* Update `alpine/Dockerfile`, `debian/Dockerfile`, and `rhel/ubi9/Dockerfile` to handle Java 25 in the `jlink` command.
* Modify `build.ps1` to include Java 25 in the `jdks_to_build` variable and update the `Test-Image` function.
* Update `updatecli/updatecli.d/jdk21.yaml` to `updatecli/updatecli.d/jdk25.yaml` and modify relevant fields for Java 25.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/gounthar/docker-agent/issues/6?shareId=XXXX-XXXX-XXXX-XXXX).
@gounthar gounthar marked this pull request as ready for review February 12, 2025 16:02
@gounthar gounthar requested a review from a team as a code owner February 12, 2025 16:02
Co-authored-by: Tim Jacomb <[email protected]>
timja
timja previously approved these changes Feb 13, 2025
Copy link
Member

@timja timja left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM

Copy link
Contributor

@lemeurherveCB lemeurherveCB left a comment

Choose a reason for hiding this comment

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

Thanks!

Thanks, Hervé! 👍

Co-authored-by: lemeurherveCB <[email protected]>
@gounthar gounthar changed the title feat(jdk): Add Java 25 target for all images feat(jdk): Add Java 25 preview target for all images Feb 13, 2025
Comment on lines +45 to +47
"17."*) options="--compress=2 --add-modules ALL-MODULE-PATH" ;; \
"21."*) options="--compress=zip-6 --add-modules ALL-MODULE-PATH" ;; \
"25"*) options="--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se" ;; \
Copy link
Contributor

@lemeurherveCB lemeurherveCB Feb 13, 2025

Choose a reason for hiding this comment

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

Having the $options variable defined instead of set -- returned with $1 is more clear for L52, 👍

"17."*) options="--compress=2 --add-modules ALL-MODULE-PATH" ;; \
"21."*) options="--compress=zip-6 --add-modules ALL-MODULE-PATH" ;; \
"25"*) options="--compress=zip-6 --add-modules java.base,java.logging,java.xml,java.se" ;; \
*) echo "Unsupported Java version ($(jlink --version 2>&1))" && exit 1 ;; \
Copy link
Contributor

@lemeurherveCB lemeurherveCB Feb 13, 2025

Choose a reason for hiding this comment

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

Question: why this comment change?

I remember questioning myself about this comment and its meaning, and AFAIR that concerns a jlink version pattern, not the Java version. (Could be wrong though)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not familiar with the history behind that previous comment. I made this change because the original comment didn't make sense to me, and I haven't encountered such a scenario.

Now that we have three different Java versions, I thought it would be better to use this comment about the Java version, even though I highly doubt we'll ever see it since the versions we pass as arguments are defined in docker-bake.hcl.

I'm fine with reverting to the old comment if needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would apply the Chesterton's fence principle here, but fine either way too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for bringing up Chesterton's fence—it's a great principle to ensure we don't remove something valuable without understanding its purpose.🙏
That being said, I believe it also highlights the importance of questioning the status quo when the original reasoning has been lost to time or is no longer relevant.

In this case, since no one seems to recall the exact context or reasoning behind the original comment, it feels like we're in a situation similar to the famous thought experiment with the monkeys, the bananas, and the ladder.
Sometimes practices or comments persist simply because 'that's how it's always been,' even when their original purpose no longer applies.

I made this change because the old comment didn't make sense to me in the current context, and I wanted to make it clearer for anyone reading or maintaining this code in the future.

Nevertheless, I'm open to reverting it if we think preserving the old comment is more valuable, but I do think it's worth revisiting these things from time to time. 😊

Copy link
Contributor

Choose a reason for hiding this comment

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

@gounthar The -preview suffix for JDK25 can be added in the tags sections of the targets to avoid failure.

Copy link
Contributor

@lemeurherveCB lemeurherveCB Mar 2, 2025

Choose a reason for hiding this comment

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

Proposing #944 to simplify tags management and to automatically take in account JDK in preview.

@gounthar gounthar marked this pull request as draft February 14, 2025 08:17
@gounthar
Copy link
Contributor Author

nanoserver image build fails.

12:18:48  Successfully built 64c61680f4d2
12:18:48  Successfully tagged jenkins4eval/agent:jdk17-nanoserver-ltsc2022
12:18:48   Service agent_nanoserver-ltsc2022_jdk17  Built
12:18:48   ---> Removed intermediate container ee7e14cbff56
12:18:48   ---> 06d651e612ee
12:18:48  Successfully built 06d651e612ee
12:18:48  Successfully tagged jenkins4eval/agent:jdk25-nanoserver-ltsc2022-preview
12:18:48   Service agent_nanoserver-ltsc2022_jdk25  Built
12:19:47  unexpected EOF
12:19:47  = BUILD: Finished building all images.
script returned exit code 1

@gounthar gounthar marked this pull request as ready for review February 27, 2025 13:38
Copy link
Contributor

@lemeurherveCB lemeurherveCB left a comment

Choose a reason for hiding this comment

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

I've compared the list of tags generated from this PR and from #944, except the "jdk25-preview" for Windows they are the same, LGTM!

Some suggestions about HCL formatting and rhel_ubi9 jdk to build.

]
platforms = debian_platforms(jdk)
}

target "rhel_ubi9" {
matrix = {
type = agent_types_to_build
jdk = [17, 21]
jdk = [17, 21, 25]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
jdk = [17, 21, 25]
jdk = jdks_to_build

todo: no need for a special treatment here anymore. (Should have been part of #890 ideally), and restore spacing part of HCL formatting.

Copy link
Contributor

Choose a reason for hiding this comment

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

Extracted from #944 in #945 FYI.

@@ -324,19 +350,21 @@ target "nanoserver" {
target = type
tags = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggestion: keep "jdk25-preview" like in the Linux distribution instead of adding only "preview" at the end of the tag, help with consistency (as all Windows tags end with the Windows flavor), and allow regrouping tags definition together without a special case for this (cf #944)

image

Alternative: wait for #944 to be merged to simplify this PR.

: "",
equal(ON_TAG, "true") ?
"${REGISTRY}/${orgrepo(type)}:${REMOTING_VERSION}-${BUILD_NUMBER}-alpine${ALPINE_SHORT_TAG}-jdk${jdk}${equal(jdk, 25) ? "-preview" : ""}"
: "",
# If there is a tag and if the jdk is the default one, add Alpine short tags
Copy link
Contributor

@lemeurherveCB lemeurherveCB Mar 2, 2025

Choose a reason for hiding this comment

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

suggestion: restore spacing on the lines below, no need for a space indentation on them.

alternative: wait for #944 to be merged.

Comment on lines +336 to +337
type = windowsagenttypes(WINDOWS_AGENT_TYPE_OVERRIDE)
jdk = jdks_to_build
Copy link
Contributor

@lemeurherveCB lemeurherveCB Mar 2, 2025

Choose a reason for hiding this comment

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

Suggested change
type = windowsagenttypes(WINDOWS_AGENT_TYPE_OVERRIDE)
jdk = jdks_to_build
type = windowsagenttypes(WINDOWS_AGENT_TYPE_OVERRIDE)
jdk = jdks_to_build

suggestion: restore spacing, part of HCL formatting.

]
platforms = ["windows/amd64"]
}

target "windowsservercore" {
matrix = {
type = windowsagenttypes(WINDOWS_AGENT_TYPE_OVERRIDE)
jdk = jdks_to_build
type = windowsagenttypes(WINDOWS_AGENT_TYPE_OVERRIDE)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

@@ -352,11 +380,13 @@ target "windowsservercore" {
target = type
tags = [
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants