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

Conversation

CerealBoy
Copy link
Contributor

Description

When a job in k8s completes, the job output will often contain the line # Received cancellation signal, interrupting even though the job itself has already completed. This appears to be a problem with the way the Cancel() method is called during the k8s job execution, and isn't validating that there's any error generated to warrant its execution.

For those looking at logs, this makes the job appear to have failed, when in all other circumstances it has succeeded.

Context

https://coda.io/d/Escalations-Feedback_dHnUHNps1YO/Pipelines-Escalations_su7FT#Pipelines-Escalations-Board_tu__K/r634&view=modal

Changes

A small logic tweak to when Cancel() is triggered based on the k8sAgentSocket.Await() call. Currently Cancel() will always be called regardless of what happens, where it should only be called if there's an error from the Await(). There's additional logic here that will generate an error log line for the job if the error is specifically not a cancellation.

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically. Tests have passed locally and via the pipeline.
  • Code is formatted (with go fmt ./...)

Copy link
Contributor

@DrJosh9000 DrJosh9000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@CerealBoy CerealBoy changed the title Only Cancel() the k8s job when Await returned an error Prevent Cancel from running when a k8s job is cancelled already Aug 19, 2024
@CerealBoy CerealBoy merged commit 266d119 into main Aug 19, 2024
1 check passed
@CerealBoy CerealBoy deleted the fix/spurious-cancellations branch August 19, 2024 04:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants