Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RB] Always cancel remote bazel run at end of CLI to prevent missing retries #8098

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions cli/remotebazel/remotebazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,9 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
log.Debugf("Invocation ID: %s", iid)

// If the remote bazel process is canceled or killed, cancel the remote run
isInvocationRunning := true
go func() {
<-ctx.Done()

if !isInvocationRunning {
return
}

// Use a non-cancelled context to ensure the remote executions are
// canceled
_, err = bbClient.CancelExecutions(context.WithoutCancel(ctx), &inpb.CancelExecutionsRequest{
Expand All @@ -905,7 +900,6 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
return 1, status.WrapError(err, "streaming logs")
}
}
isInvocationRunning = false

eg := errgroup.Group{}
var inRsp *inpb.GetInvocationResponse
Expand Down Expand Up @@ -940,7 +934,11 @@ func Run(ctx context.Context, opts RunOpts, repoConfig *RepoConfig) (int, error)
}
rsp, err := rexec.Wait(rexec.NewRetryingStream(ctx, execClient, waitExecutionStream, executionID))
if err != nil {
return fmt.Errorf("wait execution: %w", err)
return fmt.Errorf("wait execution: %v", err)
} else if rsp.Err != nil {
return fmt.Errorf("wait execution: %v", rsp.Err)
} else if rsp.ExecuteResponse.GetResult() == nil {
return fmt.Errorf("empty execute response from WaitExecution: %v", rsp.ExecuteResponse.GetStatus())
}
executeResponse = rsp.ExecuteResponse
return nil
Expand Down