Skip to content

WithMountedDirectory/WithMountedFile does not use content-based cache in withExec #6421

Closed
moby/buildkit
#4624

Description

@jedevc

TL;DR - WithMountedDirectory/WithMountedFile sometimes do not cache in scenarios where we'd expect them to, while their non-Mounted equivalents do.


See https://github.com/moby/buildkit/blob/a09112603a36532b8e44ade74ee3fd8383f4b708/solver/llbsolver/ops/exec.go#L260-L262.

This behavior is explicitly disabled in buildkit - mounts only use slow content-based cache when both:

  • The mount is not the root mount
  • The mount is read-only

This is to avoid computing expensive content-based checksums. The root mount case often makes sense for us as well: I really struggle to imagine a scenario where caching this would be super useful. It would allow refactoring of previous steps into steps that produce the exact same file system to be kept - but this doesn't often happen, since timestamps on files exist.

However, it would be more reasonable to allow non-readonly, non-root mounts to do this as well. There is also llb.ForceNoOutput, but we do rely on the output to ensure that the outputs do propagate and changes to mount content is kept.

The logic for not supporting this on read-only mounts is in: moby/buildkit#903 (comment)

We should investigate further, and attempt to remove this constraint in upstream buildkit (atm, I'm not sure I fully understand what this constraint actually is.

Activity

  1. sipsma commented on Jan 17, 2024

    @sipsma
    Contributor

    I noticed this a long time ago and was afraid it broke caching in subtle ways everywhere but could never create a practical scenario where it happened w/ dagger. That was a while back though now. Do you know of any @jedevc?

  2. jedevc commented on Jan 31, 2024

    @jedevc
    ContributorAuthor

    That was a while back though now. Do you know of any @jedevc?

    I think there's an explicit reason for this. It doesn't spring to mind 😢 Have asked on the community slack if anyone's aware" https://dockercommunity.slack.com/archives/C7S7A40MP/p1706711391769259

  3. linked a pull request that will close this issueExecOp: update content-cache mount logic #4624on Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions