-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Improve cache handling #1679
Merged
Merged
Improve cache handling #1679
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edmorley
force-pushed
the
cache-refactor
branch
from
October 30, 2024 21:10
75de602
to
3a1ce6c
Compare
edmorley
force-pushed
the
cache-refactor
branch
from
October 31, 2024 11:17
3a1ce6c
to
c245e48
Compare
Malax
approved these changes
Oct 31, 2024
Refactors cache handling to dedicated functions under `lib/cache.sh` (rather than being scattered around the buildpack), and makes the following improvements: - Ensures the cache is now also discards the cache when the package manager (or its version) changes. - Improves the build log output shown when restoring or discarding the cache. For example, if the cache was invalidated all reasons are now shown. - Stops performing unnecessary cache file copies when the cache is due to be invalidated. This required moving the cache restoration step to after the `bin/pre_compile` hook runs. - Fixes cache restoration in the case where an app's `requirements.txt` was formerly a symlink. - Adds buildpack metrics for the status of the cache and duration of cache restoration/saving. Fixes #1673. Fixes #1674. Fixes #1675. Fixes #1676. Fixes #1677. Fixes #1678. Prep for #796. Unblocks upgrading pip (since #1674 prevents pypa/pip#12950). GUS-W-16811131.
edmorley
force-pushed
the
cache-refactor
branch
from
October 31, 2024 14:45
c245e48
to
ce4ad9f
Compare
Merged
edmorley
added a commit
that referenced
this pull request
Dec 6, 2024
For apps that do not specify an explicit Python version (eg: via a `.python-version` or `runtime.txt` file), the buildpack uses a curated default version for the first build of the app. Then for subsequent builds of the app, the buildpack selects a Python version based on the version found in the build cache, so that the version used for the app doesn't change in a breaking way over time as the buildpack's own default version changes. This feature is referred to as "version pinning" and/or "sticky versions". The existing implementation of this feature pinned the version to the full Python version (eg `3.13.0`), meaning that the app would always use that exact Python version, even as newer backwards-compatible patch releases (such as `3.13.1`) become available over time. Now that we have Python major version -> latest patch version resolution support (as of #1658) and improved build output around cache invalidation reasons (as of #1679), we can switch to instead only pinning to the major Python version (eg `3.13`). This allows apps that do not specify a Python version to pick up any bug and security fixes for their major Python version the next time the app is built, whilst still keeping the compatibility properties of version pinning. Longer term, the plan is to deprecate/sunset version pinning entirely (since it leads to confusing UX / lack of parity between multiple apps deployed from the same codebase at different times, eg review apps), and the Python CNB has already dropped support for it. However, that will be a breaking change for the classic buildpack, so out of scope for now. GUS-W-17384879.
edmorley
added a commit
that referenced
this pull request
Dec 6, 2024
For apps that do not specify an explicit Python version (eg: via a `.python-version` or `runtime.txt` file), the buildpack uses a curated default version for the first build of the app. Then for subsequent builds of the app, the buildpack selects a Python version based on the version found in the build cache, so that the version used for the app doesn't change in a breaking way over time as the buildpack's own default version changes. This feature is referred to as "version pinning" and/or "sticky versions". The existing implementation of this feature pinned the version to the full Python version (eg `3.13.0`), meaning that the app would always use that exact Python version, even as newer backwards-compatible patch releases (such as `3.13.1`) become available over time. Now that we have Python major version -> latest patch version resolution support (as of #1658) and improved build output around cache invalidation reasons (as of #1679), we can switch to instead only pinning to the major Python version (eg `3.13`). This allows apps that do not specify a Python version to pick up any bug and security fixes for their major Python version the next time the app is built, whilst still keeping the compatibility properties of version pinning. Longer term, the plan is to deprecate/sunset version pinning entirely (since it leads to confusing UX / lack of parity between multiple apps deployed from the same codebase at different times, eg review apps), and the Python CNB has already dropped support for it. However, that will be a breaking change for the classic buildpack, so out of scope for now. GUS-W-17384879.
edmorley
added a commit
that referenced
this pull request
Dec 6, 2024
For apps that do not specify an explicit Python version (e.g.: via a `.python-version` or `runtime.txt` file), the buildpack uses a curated default version for the first build of the app. Then for subsequent builds of the app, the buildpack selects a Python version based on the version found in the build cache, so that the version used for the app doesn't change in a breaking way over time as the buildpack's own default version changes. This feature is referred to as "version pinning" and/or "sticky versions". The existing implementation of this feature pinned the version to the full Python version (e.g. `3.13.0`), meaning that the app would always use that exact Python version, even when newer backwards-compatible patch releases (such as `3.13.1`) became available over time. Now that we have Python major version -> latest patch version resolution support (as of #1658) and improved build output around cache invalidation reasons (as of #1679), we can switch to instead only pinning to the major Python version (e.g. `3.13`). This allows apps that do not specify a Python version to pick up any bug and security fixes for their major Python version the next time the app is built, whilst still keeping the compatibility properties of version pinning. Longer term, the plan is to deprecate/sunset version pinning entirely (since it leads to confusing UX / lack of parity between multiple apps deployed from the same codebase at different times, e.g. review apps), and the Python CNB has already dropped support for it. However, that will be a breaking change for the classic buildpack, so out of scope for now. GUS-W-17384879.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Refactors cache handling to dedicated functions under
lib/cache.sh
(rather than being scattered around the buildpack), and makes the following improvements:bin/pre_compile
hook runs.requirements.txt
was formerly a symlink.Note: The
.heroku/
namespaced cache contents are considered an internal Heroku buildpack implementation detail and should not be directly modified by anybin/{pre,post}_compile
hooks or third-party buildpacks.Fixes #1673.
Fixes #1674.
Fixes #1675.
Fixes #1676.
Fixes #1677.
Fixes #1678.
Prep for #796.
Unblocks upgrading pip (since #1674 prevents pypa/pip#12950).
GUS-W-16811131.