Repository navigation
Description
Task List
New Features:
- Scope cache by PR #2059
- Ability to automatically configure cache imports/exports (see
Seamless Configurationsection below) - Persist cache volumes on CI #1345
- (Buildkit) Merge extra traces/spans upstream to enable easier cache debuggability (see commit in my buildkit fork here)
- ✨ Ability to provide credentials for cache import/export #2477
Observability-related:
- Add ability to run Jaeger in CI integration tests, export traces and make them easily viewable
- Convert universe tests over to also use jaeger
- Run Jaeger via core.Start (requires the most basic tasks in the other epic)
- Deprecate the docker compose setup in favor of running Jaeger in core.Start, update docs accordingly
Testing:
- Add tests for local cache imports/exports
- Add tests for registry cache imports/exports (will be useful for CIs outside of GHA)
Bugs:
- 🐞 GHA Throttling causes CI to fail #2365
- (Buildkit) Allow ignoring errors when exporting remote cache moby/buildkit#2578
- (Buildkit) Remote cache import network error is fatal but should be considered a cache miss moby/buildkit#2836
Latest Updates
- Previously
- Initial gathering of ideas
- Some of the initial observability-related work. The observability is a necessary first step so we have the ability to test the new caching features and bug fixes.
- Creating proof-of-concept cue-based cache configuration
- Right now
- Gather feedback on cue-based cache configuration here
- following up on observability, goal is to get the rest of our tests converted over to use the traces and to run Jaeger as a
core.#Start(which creates a plausible path for our end users to also use it easily). This requires a few of the basic features mentioned here:core.#Startfollow-ups and enhancements #2398
- Next Steps - update cue-based cache configuration proposal based on feedback; if approved, work on cleaned-up implementation
Discussion
The overall goal here is to make it seamless for users to speed up dagger do executions through the use of caching. Ideally, users should never need to know that caching exists and they just have really fast builds automatically. It will take a while to reach that vision, but the tasks here are some basic initial steps towards it.
This of course involves new caching features in Dagger/Buildkit, but it also means we need the ability to know when caches are being used by Buildkit and how effective they are. By making caching behavior observable, we can know whether our efforts to improve performance via caching are actually working or not. The observability features we add as part of this should be helpful in general too, for both us and users.
New Features
Seamless Configuration
Update: a prototype of this has been posted as a draft for design feedback here
Right now users can only setup remote cache imports/exports using command line args that accept the same format as buildctl (cli to buildkitd). This requires the user to configure a lot on their own, which is especially hard when trying to figure out the right way to setup additive imports/exports (a la #2059).
Instead, users should be able to specify caching configuration in high-level, easily re-usable ways. This will bring the cache configuration DX to the same level as the rest of Dagger where actions are abstract+reusable.
One idea is to allow cache configuration to be specified using cue in the same way actions are. In the immediate term, this should:
- allow us to setup complicated import/export schemes automatically for the user based on their cache backend
- make it easier to support more cache backends that might be used in other CI systems
- enable integration with other features, i.e. the task above about missing support for specifying credentials to use with registry-backed caches can be solved with our existing solutions for providing secrets (read from an env var, a file, from packages in universe like 1password, etc.)
In the long term, it could setup a lot of interesting features (none of these are part of this epic, just being noted here):
- Widely shareable caches (i.e. associate known/trusted cache sources for actions under
universe.dagger.iothat can be seamlessly imported by anyone using that action) - Setting up caching infrastructure using dagger itself (i.e. create registry repository if it doesn't already exist, then use it as the cache source/target for the rest of your build)
Cache Dir import/export
This is the ability to import and export the contents of cache dirs, creating the same experience as cache imports/exports have today for normal container layers. This is most useful w/ ephemeral buildkitds such as those in CI runs.
This is an example where we need to be careful that we are actually providing benefits. There are cases where it may just be faster to not import/export the cache, such as when caching packages downloaded from a CDN. Observability related features are thus essential here. This also may mean we need a way for users to selectively choose which cache dirs they want imported/exported. Even better would be if we could figure that out automatically, but that's probably too ambitious for now.
A simple starting idea is to add support for synchronous cache import and export steps that optionally populate and export cache dirs before/after they are used. Upstream buildkit maintainers expressed interest in this too, so we could possibly collaborate with them on it.
In the longer term, this could setup more advanced features like the ability to continuously sync/prune a cache dir (using an async core.Start) with some backend, which would be a better generic fit for use cases where buildkitd is more persistent than in CI runs and handles many parallel builds.
Observability
Observability could probably be its own epic, but a few features are crucial to caching and thus tracked here.
The first step here has been to setup the ability to get traces from our CI runs. Before this, we had zero insight into whether caches were being used in integration/universe tests and how long cache imports/exports took. Now, via jaeger traces we have that basic data in the integration tests. Universe tests will be updated with this support soon too.
Additionally, effort is being put into making it easy to run Jaeger in Buildkit itself (via core.Start), which will make it plausible for users to easily replicate our tracing setup if they need it (or we want it to help them debug something).
Bug Fixes
There's a few problems in upstream Buildkit that I'd ideally like to fix sooner than later in order to maximize the chances of picking them up in the next 0.11 release (under task list above). This will save us from having to choose between A) waiting a much longer time to pick up the fixes or B) maintaining our own builds of buildkitd off of their main branch.
There's also the issue we are experiencing with throttles from GHA cache when a lot of CI runs kick off at the same time. I still need to think about what the fix should be here. This is an issue that impacts general Buildkit users too (see here), so it may be worth finding a generic solution upstream such as more configurable timeouts that "give up" quicker and just consider these 429 errors to be a cache miss.
Support for more CIs than GHA
While not a task in this epic per-se, I want to keep in mind throughout all of this that none of the features should be "overfit" to GHA, even though that's what we use for our own CI right now. Part of this will be ensuring the features work well with local and registry cache imports/exports in addition to GHA. The next version of Buildkit will likely have support for an S3 cache backend, so if this epic overlaps with that release then we should include that here too.
Longer-term Ideas
These are some ideas that I considered putting in this epic but are probably best left as longer term goals for now. Many of them involve large changes to Buildkit, which will take a while to design+implement (if we get agreement on them from upstream in the first place):
- Gateway API support for cache export, so we can more easily pick and choose what to export.
- Better additive remote cache in Buildkit
- Pluggable cache backends (either merged into Buildkit or implemented via registry-as-proxy)
- High-level summaries/analytics about cache use, built on top of observability features. I.e. the ability to collect statistics about cache performance across many runs.
NOTE: this issue is being maintained by @sipsma now, so bother me instead of Andrea about any content here :-)
Activity
sipsma commentedon Apr 13, 2022
sipsma commentedon Apr 13, 2022
aluzzardi commentedon Apr 13, 2022
TomChv commentedon Apr 14, 2022
sipsma commentedon Apr 21, 2022
sipsma commentedon Apr 22, 2022
aluzzardi commentedon Apr 22, 2022
sipsma commentedon Apr 22, 2022
TomChv commentedon Apr 22, 2022
sipsma commentedon Apr 22, 2022
sipsma commentedon Apr 22, 2022
TomChv commentedon Apr 26, 2022
sipsma commentedon Apr 28, 2022
sipsma commentedon Apr 28, 2022
mircubed commentedon Jun 22, 2022
When Erik gets back from vacation, we can review this issue to see how we can break it down into smaller bitesize issues that can be tracked in an easier way.
sipsma commentedon Jan 5, 2023
A lot of this is still relevant in an abstract way but we've moved entirely off the previous CI system and will continue to, so closing this as no longer actionable. Can be revisited for ideas on CI caching in the future.