Skip to content

Commit

Permalink
Log action errors for build directory cleanup
Browse files Browse the repository at this point in the history
There was no error reporting for failure to clean up the build
directories and this would fail creation of the same action the next
time it is executed. This is an unexpected error and we have not needed
it before, but on Windows some files may be locked. We cannot return an
error to the client, as it may retry the action and then fail directory
creation, and keep retrying.
  • Loading branch information
Nils Wireklint authored and Nils Wireklint committed Feb 7, 2024
1 parent 3b4602b commit 86ef203
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/builder/local_build_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package builder

import (
"context"
"log"
"os"
"sync"
"time"
Expand Down Expand Up @@ -125,9 +126,9 @@ func (be *localBuildExecutor) CheckReadiness(ctx context.Context) error {
return err
}

func (be *localBuildExecutor) Execute(ctx context.Context, filePool re_filesystem.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) *remoteexecution.ExecuteResponse {
func (be *localBuildExecutor) Execute(ctx context.Context, filePool re_filesystem.FilePool, monitor access.UnreadDirectoryMonitor, digestFunction digest.Function, request *remoteworker.DesiredState_Executing, executionStateUpdates chan<- *remoteworker.CurrentState_Executing) (response *remoteexecution.ExecuteResponse) {
// Timeout handling.
response := NewDefaultExecuteResponse(request)
response = NewDefaultExecuteResponse(request)
action := request.Action
if action == nil {
attachErrorToExecuteResponse(response, status.Error(codes.InvalidArgument, "Request does not contain an action"))
Expand Down Expand Up @@ -158,7 +159,12 @@ func (be *localBuildExecutor) Execute(ctx context.Context, filePool re_filesyste
util.StatusWrap(err, "Failed to acquire build environment"))
return response
}
defer buildDirectory.Close()
defer func() {
err := buildDirectory.Close()
if err != nil {
log.Printf("Failed to clean up build environment: %v\n", err)
}
}()

// Install hooks on build directory to capture file creation and
// I/O error events.
Expand Down

0 comments on commit 86ef203

Please sign in to comment.