Skip to content

Scope cache by PR #2059

Closed
Closed

Description

@aluzzardi

buildkit caching is not additive, e.g., it can only import/export cache off a single dagger do.

In our own CI, it means that each PR is overwriting the cache with that PR's content. Which in turn means each PR is invaliding each other's cache. Example:

  • PR 1 has some go changes. Cache is built using that source code and exported
  • PR 2 has different go changes. Cache is re-built using that source code, overwriting PR 1 cache
  • PR 1 has an update. It will load cache from PR 2, resulting in loss of caching from the previous run

I've no idea what a plausible workaround for this might be.

In an ideal world, buildkit would have additive caching and we'd have layers for both PR 1 and PR 2.

In the meantime, I don't know if we could play around with multiple cache-from targets, e.g.

  • Import cache from ci-main and ci-<PRID>
  • Export cache to ci-<PRID>
  • When running on main, export cache to ci-main

/cc @TomChv @gerhard

Activity

  1. TomChv commented on Apr 7, 2022

    @TomChv
    Member

    That maybe explain why Dagger CI / Build is never cache, there is a lot of change in go codebase!

    Since ImportCache and ExportCache are both arrays, I think it's possible!
    I'll try with local test and we will see where it goes!

  2. self-assigned this
    on Apr 7, 2022
  3. TomChv commented on Apr 11, 2022

    @TomChv
    Member

    After research, it's possible to import multiple cache but not export multiple.

    dagger do build --cache-to type=local,mode=max,dest=storage/main --cache-from type=local,src=storage/main --cache-from type=local,src=storage/build
    

    This example works if we separately export storage/main and storage/build.
    If we follow your idea, that it's possible.

    On the other side, we can't export to multiple destination, it's not handle by the solver but we could work on it to fix it.
    It's already handle by buildctl, just not by the solver itself.

  4. changed the title [-]dagger cache scoping[/-] [+]Scope cache by PR[/+] on Apr 12, 2022
  5. added a commit that references this issue on Apr 25, 2022
    30586d7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions