Skip to content

Commit

Permalink
filecache: restrict initial scan to group-specific dirs (#7757)
Browse files Browse the repository at this point in the history
The filecache has a `_tmp` dir which we should not scan, and we are also
considering moving OCI + firecracker images to this cache directory, to
prevent `executor.delete_build_root_on_startup` from wiping cached
images.
  • Loading branch information
bduffany authored Oct 21, 2024
1 parent d93beab commit 51808b8
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion enterprise/server/remote_execution/filecache/filecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,26 @@ func (c *fileCache) scanDir() {
}
return nil
}
if err := filepath.WalkDir(c.rootDir, walkFn); err != nil {

entries, err := os.ReadDir(c.rootDir)
if err != nil && !os.IsNotExist(err) {
log.Errorf("Error reading existing filecache dir: %q: %s", c.rootDir, err)
}
for _, entry := range entries {
// Only scan the group-specific dirs (ignore _tmp and other dirs)
if entry.Name() != "ANON" && !strings.HasPrefix(entry.Name(), "GR") {
continue
}
if !entry.IsDir() {
continue
}

groupDir := filepath.Join(c.rootDir, entry.Name())
if err := filepath.WalkDir(groupDir, walkFn); err != nil {
log.Errorf("Error scanning filecache dir: %q: %s", groupDir, err)
}
}

c.lock.Lock()
lruSize := c.l.Size()
c.lock.Unlock()
Expand Down

0 comments on commit 51808b8

Please sign in to comment.