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

SpringBoot Layered Jar not properly reusing cache #2393

Closed
manusa opened this issue Sep 26, 2023 · 2 comments · Fixed by #2398
Closed

SpringBoot Layered Jar not properly reusing cache #2393

manusa opened this issue Sep 26, 2023 · 2 comments · Fixed by #2398
Assignees
Labels
bug Something isn't working
Milestone

Comments

@manusa
Copy link
Member

manusa commented Sep 26, 2023

Description

The current approach to prepare the layers for Spring Boot Layered Jar nested generator is not working OK.

The dependency layers don't preserve the original creation date of the jar dependencies. This causes the layer digest to change from build to build. Hence, the layers can't be reused from their cached digest id.

Note

It seems that when the assembly is prepared, the timestamps for the files are lost.

Relates to

@rohanKanojia
Copy link
Member

rohanKanojia commented Sep 28, 2023

I think this issue is not just specific to SpringBoot. I think none of the container images generated by the generators are able to utilize the docker cache. We add some labels to container image in BaseGenerator
https://github.com/eclipse/jkube/blob/10051905f838d2af69002cc083fec6ab5a314b63/jkube-kit/generator/api/src/main/java/org/eclipse/jkube/generator/api/support/BaseGenerator.java#L259

This adds a label build date with timestamp in Dockerfile, this changes for every build even if no change is applied. This triggers rebuild of layers added below labels.

Here is a diff of two Dockerfiles generated on two consecutive k8s:build with no changes:

Screenshot_20230928_122736

We should change org.label-schema.build-date label to either include only date (not complete timestamp), or drop the org.label-schema.build-date label altogether.

@manusa
Copy link
Member Author

manusa commented Sep 28, 2023

I'm not really sure about this.
Have you verified that removing the label actually reuses the cached layers?
Is the label also added to the intermediate layers?

For Jib we're already basing the build on a constant date.
If this is the real underlying cause, then I think the best option is to just remove the label.

rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 28, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 28, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 28, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 29, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 29, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 29, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
rohanKanojia added a commit to rohanKanojia/jkube that referenced this issue Sep 29, 2023
…label (eclipse-jkube#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
@manusa manusa added this to the 1.15.0 milestone Oct 2, 2023
manusa pushed a commit that referenced this issue Oct 2, 2023
…label (#2393)

We add `org.label-schema.build-date` LABEL to image while creating
opinionated container images. This causes Dockerfile to be different for
every build and it doesn't utilize docker cache properly.

Signed-off-by: Rohan Kumar <rohaan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants