Skip to content

Layertools extract does not preserve last modified and last access times #28167

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

Closed
alegacy opened this issue Oct 1, 2021 · 0 comments
Closed
Assignees
Labels
type: bug A general bug
Milestone

Comments

@alegacy
Copy link

alegacy commented Oct 1, 2021

I am using the layered jar file approach to reduce the amount of data included in the context sent to the docker daemon. The Docker buildkit [1] functionality adds some intelligence around which files are sent to the Docker daemon. Unfortunately, rather than examining file checksums it appears to be looking at file timestamps. Extracting of the jar file layers using the following command does not preserve file timestamps therefore the entire set of dependency jar files is sent to the daemon each time a build is performed.

java -Djarmode=layertools -jar my-uber-jar.jar extract

I asked this question over on SO and was referred here [2].

Running that command and then checking the timestamps produces this:

$ java -Djarmode=layertools -jar my-uber-jar.jar  extract 
$ ls -l dependencies/BOOT-INF/lib/commons-*
-rw-r--r--  1 legacy  staff   327K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-codec-1.11.jar
-rw-r--r--  1 legacy  staff   204K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-io-2.5.jar
-rw-r--r--  1 legacy  staff   490K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-lang3-3.8.1.jar
-rw-r--r--  1 legacy  staff    60K Oct  1 09:23 dependencies/BOOT-INF/lib/commons-logging-1.2.jar
-rw-r--r--  1 legacy  staff   2.1M Oct  1 09:23 dependencies/BOOT-INF/lib/commons-math3-3.6.1.jar

...and then running it again ~5 minutes later it produces a fresh set of timestamps:

$ java -Djarmode=layertools -jar my-uber-jar.jar extract 
$ ls -l dependencies/BOOT-INF/lib/commons-*
-rw-r--r--  1 legacy  staff   327K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-codec-1.11.jar
-rw-r--r--  1 legacy  staff   204K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-io-2.5.jar
-rw-r--r--  1 legacy  staff   490K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-lang3-3.8.1.jar
-rw-r--r--  1 legacy  staff    60K Oct  1 09:29 dependencies/BOOT-INF/lib/commons-logging-1.2.jar
-rw-r--r--  1 legacy  staff   2.1M Oct  1 09:29 dependencies/BOOT-INF/lib/commons-math3-3.6.1.jar

[1] https://docs.docker.com/develop/develop-images/build_enhancements/
[2] https://stackoverflow.com/questions/69406916/java-layertools-extract-does-not-preserve-timestamps

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 1, 2021
@philwebb philwebb added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 1, 2021
@philwebb philwebb added this to the 2.4.x milestone Oct 1, 2021
@wilkinsona wilkinsona changed the title java layertools extract does not preserve timestamps Layertools extract does not preserve last modified and last access times Oct 4, 2021
@wilkinsona wilkinsona self-assigned this Oct 4, 2021
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.12 Oct 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants