Skip to content

Commit

Permalink
Switch around the error handling on Await to better proceed with job …
Browse files Browse the repository at this point in the history
…completion
  • Loading branch information
CerealBoy committed Aug 19, 2024
1 parent 4d5d84c commit 2642551
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions internal/job/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1269,16 +1269,16 @@ func (e *Executor) kubernetesSetup(ctx context.Context, k8sAgentSocket *kubernet
// If the k8s client is interrupted because the "server" agent is
// stopped or unreachable, we should stop running the job.
err := k8sAgentSocket.Await(ctx, kubernetes.RunStateInterrupt)
// If the k8s client is interrupted because our own ctx was cancelled,
// then the job is already stopping, so there's no point logging an
// error.
if errors.Is(err, context.Canceled) {
return
}
if err != nil {
// If the k8s client is interrupted because our own ctx was cancelled,
// then the job is already stopping, so there's no point logging an
// error.
if !errors.Is(err, context.Canceled) {
e.shell.Errorf("Error waiting for client interrupt: %v", err)
}
// If there's an error from Await, we should Cancel the job.
e.Cancel()
e.shell.Errorf("Error waiting for client interrupt: %v", err)
}
e.Cancel()
}()
return nil
}

0 comments on commit 2642551

Please sign in to comment.