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

feat: cancel jobs that do not start in time #11

Merged
merged 9 commits into from
Jan 24, 2024
Merged

Conversation

lucaspin
Copy link
Collaborator

Motivation

Currently, if the Kubernetes job created by the controller does not start at all for whatever reason, it will only be deleted when the activeDeadlineSeconds set by the controller for job is reached.

The controller currently uses an active deadline of 24h – that's how long a Semaphore job can run – but it would be useful to handle jobs that do not start at all differently.

Solution

A new JOB_START_TIMEOUT parameter is added. If that timeout is reached and the Kubernetes job has not started, the Kubernetes job is deleted.

How to know if a Kubernetes job started properly?

It depends on the Kubernetes version:

  • For version 1.24+, we can use the JobReadyPods feature gate, avoiding trips to the Kubernetes API.
  • For version <1.24, we directly check if there's a properly running pod for the Kubernetes job.

radwo
radwo previously approved these changes Jan 24, 2024
pkg/checks/checks.go Outdated Show resolved Hide resolved
@lucaspin lucaspin merged commit 46e2e12 into main Jan 24, 2024
1 check passed
@lucaspin lucaspin deleted the job-start-timeout branch January 24, 2024 23:58
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