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

Opt-in layer caching #151

Closed
wants to merge 5 commits into from
Closed

Opt-in layer caching #151

wants to merge 5 commits into from

Conversation

ekcasey
Copy link
Member

@ekcasey ekcasey commented Oct 12, 2020

Fixes #132

Note:
Parts of this change were a bit awkward b/c the buildpack spec is missing the restore phase. However, I think adding a restore phase and/or reorganizing the buildpack spec is beyond the scope of this issue.

Signed-off-by: Emily Casey <[email protected]>
@ekcasey ekcasey requested a review from a team as a code owner October 12, 2020 21:56
@ekcasey ekcasey added this to the Buildpack 0.5 milestone Oct 12, 2020
@ekcasey ekcasey linked an issue Oct 12, 2020 that may be closed by this pull request
Signed-off-by: Emily Casey <[email protected]>
buildpack.md Outdated Show resolved Hide resolved
buildpack.md Outdated Show resolved Hide resolved
buildpack.md Outdated

- Whether files in the `<app>` directory have changed since the layer was created.
- Whether the environment has changed since the layer was created.
- Whether the buildpack version has changed since the layer was created.
- Whether new application dependency versions have been made available since the layer was created.

At the start of the build phase a buildpack MAY find:
- Partial `<layers>/<layer>.toml` files describing layers from the previous builds. The restored Layer Content Metadata SHALL NOT contain `launch`, `build`, or `cache` booleans.
Copy link
Member

Choose a reason for hiding this comment

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

Given that this might be surprising, maybe we should call-out that it "SHALL NOT" even if those values were set on a previous build.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

ekcasey and others added 2 commits October 13, 2020 10:43
Copy link
Member

@sclevine sclevine left a comment

Choose a reason for hiding this comment

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

Approving, but see comment on .ignore

buildpack.md Outdated
- MUST NOT store the layer or the Layer Content Metadata in the cache.
At the end of each individual buildpack's build phase:
- The lifecycle:
- MUST rename `<layers>/<layer>/` to `<layers>/<layer>.ignore/` for all layers where `launch = false`, `build = false`, and `cache = false`.
Copy link
Member

Choose a reason for hiding this comment

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

Do we need to state how the lifecycle treats layers with a .ignore suffix? An interpretation of this could suggest that <layer>.ignore.toml controls the behavior of the ignored layer, when really we're just trying to get the layer out of the way / change its path.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, given we only rename to <layer>.ignore when all of launch, build, and cache are false, technically the lifecycle doesn't need to treat a layer with an .ignore suffix any differently than a regular layer. The lifecycle already does nothing with this type of layer.

However, I can add a sentence to clear up the intent behind the rename here.

@ekcasey
Copy link
Member Author

ekcasey commented Oct 14, 2020

There was one oversight in the original design of this RFC:

Original Assumption: We assumed that Bash buildpacks would be able to easily opt into layer reuse by appending lines to .toml. E.g:

echo "launch = true" >> layer.toml

Problem: However, b/c launch, build, and cache are top level keys they cannot be set this way. The above command would add a launch key to the [metadata] table, not the top level

Proposed Resolution: Therefore, after some discussion in slack we have decided to hold this change and merge it with another change that moves these bools into a label table. E.g

[layer]
launch = true
build = false
cache = false

Since we are moving the keys, this would also be an opportunity to rename them if we wish to before 1.0.

Result To avoid blocking buildpack API 0.5 on the proposed changes I am moving this change to the buildpack API 0.6 milestone and converting this PR to a draft.

TODO After buildpack API 0.5 is release and the buildpack/0.6 branch is created, this PR should be pointed at the new branch.

@ekcasey ekcasey marked this pull request as draft October 14, 2020 20:05
@ekcasey ekcasey modified the milestones: Buildpack 0.5, Buildpack 0.6 Oct 14, 2020

Layers marked `launch = false`, `build = false`, and `cache = false` behave like temporary directories, available only to the authoring buildpack, that exist for the duration of a single build.
The lifecycle restores all layers from previous builds as ignored layers. Buildpacks MUST set `launch`, `build`, and/or `cache` in `<layers>/<layer>.toml` to use a restored layer.
Copy link
Member

Choose a reason for hiding this comment

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

It might be worth clarifying that "as ignored layers" means the types flags are set to false in the toml file, otherwise this could be interpreted to mean that the directory is also named with .ignore.

- The lifecycle:
- MUST either restore the entire `<layers>/<layer>.toml` file and corresponding `<layers>/<layer>/` directory from any previous build to the same paths or
- MUST restore neither the `<layers>/<layer>.toml` file nor corresponding `<layers>/<layer>/` directory.
- The lifecycle MUST do both or neither of the following:
Copy link
Member

Choose a reason for hiding this comment

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

Is it worth calling out that "both" is for cache = true and "neither" is for cache = false?

Copy link
Member

Choose a reason for hiding this comment

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

Also there is that edge case where cache = false and launch = true. I don't know if that's too much detail...

Choose a reason for hiding this comment

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

I think it's important that the spec will be clear enough and explain all of the cases. I'll try to make it clearer.

7. Write a partial Bill-of-Material to `<layers>/launch.toml` describing any provided application dependencies.
8. Write a partial Bill-of-Material to `<layers>/build.toml` describing any provided build dependencies.
1. Provide the application with dependencies for launch in `<layers>/<layer>`.
1. Reuse application dependencies from a previous image by appending by `launch = true` to `<layers>/<layer>.toml`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
1. Reuse application dependencies from a previous image by appending by `launch = true` to `<layers>/<layer>.toml`.
1. Reuse application dependencies from a previous image by appending `launch = true` to `<layers>/<layer>.toml`.

Copy link
Member

@natalieparellano natalieparellano Mar 9, 2021

Choose a reason for hiding this comment

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

This also requires that the buildpack does NOT create a <layers>/<layer> of its own... IDK if that is implied or would be worth spelling out. Personally I found myself re-reading this a couple of times...

@natalieparellano
Copy link
Member

It might make sense to include #185 in this PR, so that it could all go in together. I had a question about how #185 should be reflected, probably it affects this PR as well: #185 (comment)

@ekcasey ekcasey linked an issue Mar 11, 2021 that may be closed by this pull request
@yaelharel
Copy link

Hi @ekcasey, I opened #209 so I think this PR can be closed (sorry but I don't have permissions to do that).

@ekcasey
Copy link
Member Author

ekcasey commented Mar 25, 2021

Closing in favor of #209

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

Successfully merging this pull request may close these issues.

6 participants