Skip to content

Conversation

Josh-Matsuoka
Copy link
Contributor

Addresses https://issues.redhat.com/browse/OPENJDK-3646

Creates all of the temporary files used by the jlink workflow (deps.txt, etc) under /tmp/jlink, this can be controlled by the S2I_JLINK_TEMP_PATH variable. Once the jlink workflow completes it then checks S2I_DELETE_SOURCE and removes /tmp/jlink if set.

To test:

  • Set S2I_DELETE_SOURCE to default to true for testing
diff --git a/modules/s2i/core/module.yaml b/modules/s2i/core/module.yaml
index af3123c..c74e57d 100644
--- a/modules/s2i/core/module.yaml
+++ b/modules/s2i/core/module.yaml
@@ -110,7 +110,7 @@ envs:
 - name: S2I_DELETE_SOURCE
   description: ^
     Delete source files at the end of build.  Defaults to true.
-  example: "false"
+  example: "true"
 
 - name: S2I_ENABLE_JLINK
   description: ^
  • Build the tech preview image:
cekit --descriptor ubi9-openjdk-21.yaml build podman
  • Set up a new Openshift Project
oc new-project jlink-dev
oc project jlink-dev
oc create imagestream openjdk-21-jlink-tech-preview
  • Push the tech preview images to the created imagestream
podman tag openjdk-tech-preview/openjdk-21-jlink-rhel9:latest default-route-openshift-image-registry.apps-crc.testing/jlink-dev/openjdk-21-jlink-tech-preview:latest
podman push default-route-openshift-image-registry.apps-crc.testing/jlink-dev/openjdk-21-jlink-tech-preview:latest
  • Run the template and observe the builds
oc create -f templates/jlink/jlinked-app.yaml
oc process -n jlink -f templates/jlink/jlinked-app.yaml -p APP_URI=https://github.com/jboss-container-images/openjdk-test-applications -p JDK_VERSION=21 -p REF=master -p CONTEXT_DIR=quarkus-quickstarts/getting-started-3.9.2-uberjar -p TARGET_PORT=8080 -p SERVICE_PORT=8080 -p APPNAME=quarkus-3646 | oc create -f -
  • Check the logs for quarkus-3646-jlink-s2i-jdk-21-2. Look at the end of the build and check for the logging indicating that the temp directory was removed:
++ find /tmp/jlink -maxdepth 0 -type d '!' -empty
+ '[' -n /tmp/jlink ']'
+ log_info 'Cleaning up temporary file directory /tmp/jlink'
+ local 'message=Cleaning up temporary file directory /tmp/jlink'
+ echo -e 'INFO Cleaning up temporary file directory /tmp/jlink'
INFO Cleaning up temporary file directory /tmp/jlink
+ rm -rf /tmp/jlink

@Josh-Matsuoka Josh-Matsuoka requested review from jmtd and sefroberg March 4, 2025 19:17
Copy link

@sefroberg sefroberg left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@jmtd
Copy link
Member

jmtd commented Mar 5, 2025

This looks good: I'd like to see a Behave test to check the behaviour.

@jmtd
Copy link
Member

jmtd commented Mar 5, 2025

S2I_JLINK_TEMP_PATH is defined in modules/jlink, and is referenced by scripts in that module as well as modules/s2i/bash/artifacts/usr/local/s2i/assemble. At the moment, modules/s2i/bash requires the jlink module, so S2I_JLINK_TEMP_PATH is guaranteed to be defined, but, separately I was wondering whether that dependency should be removed (moved to the image descriptor for the TP image, i.e., ubi9-openjdk-21 at this point).

It doesn't matter so long as we build the tech-preview image from the jlink-dev branch and don't build the other product images from that branch, but a consequence is if you did build the other product images frmo this branch, all the builder images would pick up the jlink module. That would be a blocker for a future merge down to ubi9.

Copy link
Member

@jmtd jmtd left a comment

Choose a reason for hiding this comment

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

as per inline comments

@jmtd
Copy link
Member

jmtd commented Mar 5, 2025

FWIW I think it would be easiest to extend the existing jlink tests that were fixed in jlink-dev, perhaps merge that back to your PR branch first?

Copy link

@sefroberg sefroberg left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Given s2i build https://github.com/rh-openjdk/openjdk-container-test-applications from quarkus-quickstarts/getting-started-3.9.2-uberjar
| variable | value |
| S2I_ENABLE_JLINK | true |
| S2I_DELETE_SOURCE | true |
Copy link
Member

Choose a reason for hiding this comment

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

The default value of S2I_DELETE_SOURCE is true. What we really need to test is that, when set to false, we don't clean them up. I guess testing both scenarios is worthwhile.

@jmtd jmtd merged commit 6d8bb45 into rh-openjdk:jlink-dev Mar 7, 2025
0 of 6 checks passed
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