-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Enable fallback keys (multiple restore keys) in Pipeline Caching #10842
Comments
We've iterated on how this will look in the YAML and there are a few changes.
An example:
|
The equivalent "task" form of this would be ... steps:
- task: Cache@0
inputs:
key: $(Agent.OS) | Gemfile.lock | **/*.gemspec,!./junk/**
path: vendor/bundle
restoreKeys: |
$(Agent.OS) | Gemfile.lock
$(Agent.OS) |
Related to fallback is the concept of a "rolling cache". This type of cache is usually produced in a compilation process that had hundreds or thousands of files which impact the cache contents. There is no well-defined file (or set of file) that the cache key can be based on --- the best identifier for the cache is basically the SHA of the commit being built. Note: we probably need a separate issue to track this concept, but raising it here since it relates to restore keys and look up. The following examples cover one way for matching on restore and how rolling might work ... Example 1 (no restore keys)steps:
- cache:
key: a | b | c Save key
Restore lookup
Example 2 (with restore keys)steps:
- cache:
key: a | b | c
restoreKeys:
- a | b
- a Save key
Restore lookup
Example 3 (rolling)
Save key
Restore lookup
|
Fallback keys: microsoft/azure-pipelines-tasks#10842 input globbing: microsoft/azure-pipelines-tasks#10859 Relative paths: microsoft/azure-pipelines-tasks#10858 Only save when restore runs: microsoft/azure-pipelines-tasks#10907 Retries on timeouts: microsoft/azure-pipelines-tasks#10935
* New features for Pipline Cachings: Fallback keys: microsoft/azure-pipelines-tasks#10842 input globbing: microsoft/azure-pipelines-tasks#10859 Relative paths: microsoft/azure-pipelines-tasks#10858 Only save when restore runs: microsoft/azure-pipelines-tasks#10907 Retries on timeouts: microsoft/azure-pipelines-tasks#10935 * Some PR feedback
This is released. Closing the issue. |
This kind of requires a lot of line noise if one wishes to safely escape strings in the key from being considered as paths, while also breaking longer key over yaml lines to improve readability and version control, as we must also insert the line wrapps after each pipe and escape the quotes for yaml. parameters:
key: 'build_cache_v1'
workspace: '/opt/underlay_ws'
path: '/opt/underlay_ws/build'
steps:
- task: CacheBeta@0
inputs:
key: "
\"${{parameters.key}}\" | \
\"$(Container.OS)\" | \
\"$(Container.OSArchitecture)\" | \
\"$(System.PullRequest.PullRequestNumber)\" | \
${{parameters.workspace}}/checksum.txt"
path: ${{parameters.path}}
displayName: Cache ${{parameters.key}} |
@ruffsl - would this syntax work for you:
|
That is a lot more elegant! Thank you. |
Did the |
@takluyver - the rolling idea has not been implemented yet, only the restoreKeys. |
OK, thanks. We can work with that. It would be good to see it in the docs, though - #5694. 🙂 |
Yup, we will be updating the docs soon. :) |
What does the new way look like? |
That was nearly 10 months ago. Perhaps you could leave github issues open until the documentation is done? Otherwise it seems documentation never actually happens? And without it are they really completed features? |
The documentation says a cache is "immutable" - created once and frozen in time and then points to this feature but I don't see any correlation between immutability and cache fallbacks. Does this feature allow my cache to be loaded by a fixed key "foo", the directory updated by the pipeline (say by downloading new dependencies) and then the cache will be updated from the cache directory if the build changes the contents? In other words is the cache write once and does this feature change that? Also, fwiw the
|
Right now, a Pipeline Caching entry lookup can either be an exact hit or otherwise it is a miss. This can help with many scenarios, but is less effective for others.
Here's my thinking on how we expand from that:
On saving a cache entry, it will continue to be stored at a specific key with an immutable value, however, one will be able to query it with multiple exact keys or key prefixes. Here's an example:
For saving, the cache entry will be stored at this "path":
Lookups will occur in the following order until an entry is found. Should a particular lookup return multiple entries, the one that was most recently created will be selected.
The text was updated successfully, but these errors were encountered: