Skip to content

Commit 4a892b6

Browse files
vfs: don't try to add files to filecache when vfs is enabled (#9103)
This fixes some log spam since these adds can never succeed.
1 parent b1acfeb commit 4a892b6

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

enterprise/server/remote_execution/workspace/workspace.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,11 @@ func (ws *Workspace) UploadOutputs(ctx context.Context, cmd *repb.Command, execu
387387
return status.WrapError(err, "apply overlay upperdir changes")
388388
}
389389
}
390+
// Don't try to add files to the filecache if VFS is enabled. We use hard links to store data in the file
391+
// cache and hard links across filesystems are not possible.
392+
addToFileCache := ws.vfs == nil
390393
var err error
391-
txInfo, err = dirtools.UploadTree(egCtx, ws.env, ws.dirHelper, instanceName, digestFunction, ws.inputRoot(), cmd, executeResponse.Result)
394+
txInfo, err = dirtools.UploadTree(egCtx, ws.env, ws.dirHelper, instanceName, digestFunction, ws.inputRoot(), cmd, executeResponse.Result, addToFileCache)
392395
return err
393396
})
394397
var logsMu sync.Mutex

server/cache/dirtools/dirtools.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ func (f *fileToUpload) FileNode() *repb.FileNode {
286286
}
287287
}
288288

289-
func uploadMissingFiles(ctx context.Context, uploader *cachetools.BatchCASUploader, env environment.Env, filesToUpload []*fileToUpload, instanceName string, digestFunction repb.DigestFunction_Value) (alreadyPresentBytes int64, _ error) {
289+
func uploadMissingFiles(ctx context.Context, uploader *cachetools.BatchCASUploader, env environment.Env, filesToUpload []*fileToUpload, instanceName string, digestFunction repb.DigestFunction_Value, addToFileCache bool) (alreadyPresentBytes int64, _ error) {
290290
ctx, cancel := context.WithCancel(ctx)
291291
defer cancel()
292292

@@ -345,17 +345,17 @@ func uploadMissingFiles(ctx context.Context, uploader *cachetools.BatchCASUpload
345345
fc := env.GetFileCache()
346346
for batch := range batches {
347347
alreadyPresentBytes += batch.presentBytes
348-
if err := uploadFiles(ctx, uploader, fc, batch.files); err != nil {
348+
if err := uploadFiles(ctx, uploader, fc, batch.files, addToFileCache); err != nil {
349349
return 0, err
350350
}
351351
}
352352
return alreadyPresentBytes, nil
353353
}
354354

355-
func uploadFiles(ctx context.Context, uploader *cachetools.BatchCASUploader, fc interfaces.FileCache, filesToUpload []*fileToUpload) error {
355+
func uploadFiles(ctx context.Context, uploader *cachetools.BatchCASUploader, fc interfaces.FileCache, filesToUpload []*fileToUpload, addToFileCache bool) error {
356356
for _, uploadableFile := range filesToUpload {
357357
// Add output files to the filecache.
358-
if fc != nil {
358+
if fc != nil && addToFileCache {
359359
node := uploadableFile.FileNode()
360360
if err := fc.AddFile(ctx, node, uploadableFile.fullPath); err != nil {
361361
log.Warningf("Error adding file to filecache: %s", err)
@@ -446,7 +446,7 @@ func handleSymlink(dirHelper *DirHelper, rootDir string, cmd *repb.Command, acti
446446
return nil
447447
}
448448

449-
func UploadTree(ctx context.Context, env environment.Env, dirHelper *DirHelper, instanceName string, digestFunction repb.DigestFunction_Value, rootDir string, cmd *repb.Command, actionResult *repb.ActionResult) (*TransferInfo, error) {
449+
func UploadTree(ctx context.Context, env environment.Env, dirHelper *DirHelper, instanceName string, digestFunction repb.DigestFunction_Value, rootDir string, cmd *repb.Command, actionResult *repb.ActionResult, addToFileCache bool) (*TransferInfo, error) {
450450
startTime := time.Now()
451451
outputDirectoryPaths := make([]string, 0)
452452
filesToUpload := make([]*fileToUpload, 0)
@@ -536,7 +536,7 @@ func UploadTree(ctx context.Context, env environment.Env, dirHelper *DirHelper,
536536

537537
// Upload output files to the remote cache and also add them to the local
538538
// cache since they are likely to be used as inputs to subsequent actions.
539-
alreadyPresentBytes, err := uploadMissingFiles(ctx, uploader, env, filesToUpload, instanceName, digestFunction)
539+
alreadyPresentBytes, err := uploadMissingFiles(ctx, uploader, env, filesToUpload, instanceName, digestFunction, addToFileCache)
540540
if err != nil {
541541
return nil, err
542542
}

server/cache/dirtools/dirtools_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ func TestUploadTree(t *testing.T) {
653653
dirHelper := dirtools.NewDirHelper(rootDir, tc.cmd, fs.FileMode(0o755))
654654

655655
actionResult := &repb.ActionResult{}
656-
txInfo, err := dirtools.UploadTree(ctx, env, dirHelper, "", repb.DigestFunction_SHA256, rootDir, tc.cmd, actionResult)
656+
txInfo, err := dirtools.UploadTree(ctx, env, dirHelper, "", repb.DigestFunction_SHA256, rootDir, tc.cmd, actionResult, true /*=addToFileCache*/)
657657
require.NoError(t, err)
658658

659659
assert.Equal(t, tc.expectedInfo.FileCount, txInfo.FileCount)

0 commit comments

Comments
 (0)