diff --git a/internal/job/executor.go b/internal/job/executor.go index ba48243465..c15b94ae80 100644 --- a/internal/job/executor.go +++ b/internal/job/executor.go @@ -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 }