From ab17c1dd93abe1ece92d04b31cd4c0bc6711cebe Mon Sep 17 00:00:00 2001 From: Justin Chadwell Date: Mon, 5 Feb 2024 15:36:14 +0000 Subject: [PATCH] exec: allow content-cache for root selected mounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These mounts are actually safe, as suggested by Erik on slack: > Is it correct that this wouldn’t be a problem in the case where the > selector of the mount is just “/“? Because then there’s no “hidden” > files. > > If so, maybe there’s a path to enabling content cache for rw mounts > that are from “/“. Then you could also get the same end behavior by > not using selectors and instead always copying the subdir you want to > mount to scratch. This patch adds a check for this case, and explicitly enables content-based cache for these cases. Co-authored-by: Erik Sipsma Signed-off-by: Justin Chadwell --- solver/llbsolver/ops/exec.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/solver/llbsolver/ops/exec.go b/solver/llbsolver/ops/exec.go index 6becead59..762100657 100644 --- a/solver/llbsolver/ops/exec.go +++ b/solver/llbsolver/ops/exec.go @@ -318,6 +318,10 @@ func (e *ExecOp) getMountDeps() ([]dep, error) { // if the mount is read-only, then it's also safe, since it can't // be modified by the operation contentBasedCache = true + } else if sel == pb.RootMount { + // if the mount mounts the entire source, then it's also safe, + // since there are no unselected "sneaky" files + contentBasedCache = true } if m.Dest == pb.RootMount {