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

Prevent Cancel from running when a k8s job is cancelled already #2935

Merged
merged 2 commits into from
Aug 19, 2024
Merged
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
6 changes: 5 additions & 1 deletion internal/job/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -1268,10 +1268,14 @@ func (e *Executor) kubernetesSetup(ctx context.Context, k8sAgentSocket *kubernet
go func() {
// 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 err := k8sAgentSocket.Await(ctx, kubernetes.RunStateInterrupt); err != nil && !errors.Is(err, context.Canceled) {
if errors.Is(err, context.Canceled) {
return
}
if err != nil {
e.shell.Errorf("Error waiting for client interrupt: %v", err)
}
e.Cancel()
Expand Down