Skip to content

Add option to customize build cache volume names #28292

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
wants to merge 8 commits into from

Conversation

TSRBerry
Copy link

This PR adds the option cacheVolumeNames to the spring-boot maven/gradle plugins, which allows the specification of custom build cache volume names.

At the moment the name can be customized for the following volume types:

  • launch
  • build

In Gradle specifying cache volume names can be done like this:

bootBuildImage {
    cacheVolumeNames = [
        "build": "example-build-cachevol",
        "launch": "example-launch-cachevol"
    ]
}

This PR should resolve #25994.

@pivotal-cla
Copy link

@jeliebig Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

@pivotal-cla
Copy link

@jeliebig Thank you for signing the Contributor License Agreement!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 11, 2021
@scottfrederick scottfrederick self-assigned this Oct 13, 2021
@scottfrederick scottfrederick added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 18, 2021
scottfrederick pushed a commit that referenced this pull request Oct 19, 2021
This commit adds configuration to the Maven and Gradle plugins to
allow specifying the names of build and launch cache volumes provided
to the CNB builder.

See gh-28292
@scottfrederick scottfrederick added this to the 2.6.0-RC1 milestone Oct 19, 2021
@scottfrederick
Copy link
Contributor

scottfrederick commented Oct 19, 2021

@jeliebig Thank you very much for your contribution. Your commits have been merged with some changes that you can see in this commit.

After reviewing the Cloud Native Buildpacks changes that this issue was meant to match, we decided that we needed an approach that provided a DSL for configuring the caches instead of a simpler map structure. We also have a desire to support other cache options in the future to align with the CNB direction documented in an RFC. I've added #28386 and #28387 to track these future cache options in Spring Boot.

@TSRBerry
Copy link
Author

TSRBerry commented Oct 20, 2021

Thank you for doing this!

For future PRs I would like to ask a few questions if you don't mind.
It seems like you had to do a lot of work to merge my PR which I feel like is not optimal. Do you have any feedback for me like things that I could work on, so you don't have to spend so much time on my PRs in the future?
Is there any way for me to discuss the approach with you guys beforehand? I would like to avoid that you guys need to do more work just to merge a feature I would like to have, because I couldn't provide a good implementation of it.

Before I created this PR I have done a lot of local testing for a multiö-project build, because my goal is to get caching working for CI builders. During my tests I also implemented cache-images, but trying them out showed no difference to a regular build. The only way I was able to get caching working was to have a previous image of my project which would then provide the metadata and layers for the used buildpacks. Am I doing something wrong or are cache-volumes and cache-images really not used in any way? Even without my changes I wasn't able to see a difference for a regular build and a build with cache-volumes.

I would like to learn more about that and already read a lot of cnb documentation about the lifecycle to get a good understanding about how caching is supposed to work. But since buildpacks can choose if and how layers should be cached, no improvements can be made if a reusable layer does not get cached in the first place. I especially noticed that paketo-buildpacks/bellsoft-liberica would never cache JRE layers even tho they could be used for other builds as long as the java version does not change. If you want to reuse these JRE layers you need to have a previous image from a previous build that they can be exported from. This is just an example, since I saw that most of my build time is distributed to downloading JRE for every CI build. Which leads me to my question, are there any optimizations that I could do to improve this situation? Does spring-boot want these kind of improvements to be made?

Thank you for your time. I hope my questions don't bother you too much.

@scottfrederick
Copy link
Contributor

scottfrederick commented Oct 20, 2021

It seems like you had to do a lot of work to merge my PR which I feel like is not optimal. Do you have any feedback for me like things that I could work on, so you don't have to spend so much time on my PRs in the future?

This was not a case of you doing anything wrong. The original issue #25994 was written to track work that was done in the pack CLI so we can try to maintain parity across CNB tooling, but the issue did not have enough detail and design documented in it. We will often tag issues like that with pending-design to indicate that more work needs to be done, but we did not do that in this case. After looking at your contribution and the CNB RFC that discusses caching changes, it was apparent that we should design this feature with future work in mind. I was keen to get this change into the upcoming 2.6.0-RC1 release so I made the changes without further discussion. Given more time, we could have discussed the design and implementation in the PR.

Even though further work was done, your contribution was very thorough and complete. Thanks again for that.

Is there any way for me to discuss the approach with [the team] beforehand?

You are welcome to add comments to an issue to get clarity on a proposed feature or to say that you'd like to work on a PR for the issue. Sometimes that will prompt us to look closer to see if there is additional design that should be taken into account, and discuss the implementation.

Which leads me to my question, are there any optimizations that I could do to improve [the caching] situation?

I think everything else you've mentioned here is under the control of the CNB builder and buildpacks. Spring Boot can configure caches for the lifecycle but only buildpacks can decide what to cache. If you're using the Paketo builder, you can raise issues in the appropriate Paketo GitHub project or start a discussion with that community. Caching of JRE/JDK specifically has been discussed with the Paketo team in the past.

@TSRBerry
Copy link
Author

Thank you so much for answering my questions!

I hope I can create a new PR for this project soon!

@jdupont22
Copy link

jdupont22 commented Apr 19, 2023

Hi @TSRBerry, @scottfrederick

Thanks for the try (2021 i know), but buildpack and pack cli now support this kind of use case.
Please see pack --cache

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

Successfully merging this pull request may close these issues.

Allow build image cache volume names to be customized
6 participants