From 670db218f1bbd54f94e42ca2989b2112115a2b22 Mon Sep 17 00:00:00 2001 From: Maggie Lou Date: Thu, 19 Dec 2024 16:00:10 -0600 Subject: [PATCH 1/2] [RB] Fix error handling --- cli/remotebazel/remotebazel.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cli/remotebazel/remotebazel.go b/cli/remotebazel/remotebazel.go index 2749a0002cc..53d486efe3f 100644 --- a/cli/remotebazel/remotebazel.go +++ b/cli/remotebazel/remotebazel.go @@ -940,7 +940,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 From 5ac2881487084c3241c722884480e778732bf002 Mon Sep 17 00:00:00 2001 From: Maggie Lou Date: Thu, 19 Dec 2024 16:23:48 -0600 Subject: [PATCH 2/2] [RB] Always cancel remote bazel run at end of CLI to prevent missing retries --- cli/remotebazel/remotebazel.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cli/remotebazel/remotebazel.go b/cli/remotebazel/remotebazel.go index 53d486efe3f..29a65e54ede 100644 --- a/cli/remotebazel/remotebazel.go +++ b/cli/remotebazel/remotebazel.go @@ -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{ @@ -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