diff --git a/cli/integrationtest/controlplane_test.go b/cli/integrationtest/controlplane_test.go index 34fde986..0a436a3a 100644 --- a/cli/integrationtest/controlplane_test.go +++ b/cli/integrationtest/controlplane_test.go @@ -1311,10 +1311,6 @@ func TestCancelJob(t *testing.T) { runTygerSucceeds(t, "run", "cancel", runId) - // force the sweep to run to terminate the pod - _, err := controlplane.InvokeRequest(context.Background(), http.MethodPost, "v1/runs/_sweep", nil, nil) - require.NoError(err) - waitForRunCanceled(t, runId) // Check that the run failed because it was canceled. diff --git a/cli/internal/cmd/run.go b/cli/internal/cmd/run.go index 7d0820cb..049821dd 100644 --- a/cli/internal/cmd/run.go +++ b/cli/internal/cmd/run.go @@ -311,7 +311,9 @@ beginWatch: } end: - mainWg.Wait() + if runFailedErr == nil { + mainWg.Wait() + } if logs { // The run has completed and we have received all data. We just need to wait for the logs to finish streaming, diff --git a/server/ControlPlane/Database/Repository.cs b/server/ControlPlane/Database/Repository.cs index 880afd61..240d455e 100644 --- a/server/ControlPlane/Database/Repository.cs +++ b/server/ControlPlane/Database/Repository.cs @@ -534,7 +534,7 @@ await _resiliencePipeline.ExecuteAsync(async cancellationToken => SELECT run FROM runs WHERE id = $1 - AND status NOT IN ('Failed', 'Succeeded', 'Canceled') + AND status NOT IN ('Failed', 'Succeeded', 'Canceled', 'Canceling') FOR UPDATE """, conn) { @@ -550,7 +550,7 @@ FOR UPDATE await using var reader = await readRun.ExecuteReaderAsync(cancellationToken); if (!await reader.ReadAsync(cancellationToken)) { - // The run is already in a terminal state so we don't do anything + // The run is already in a terminal or canceling state so we don't do anything return; }