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

fix: delete active jobs right away when job finishes even when TTLSecondsAfterFinished is set #667

Conversation

CecileRobertMichon
Copy link
Contributor

@CecileRobertMichon CecileRobertMichon commented Aug 27, 2024

What type of PR is this?

/kind bug

What this PR does / why we need it:

When TTLSecondsAfterFinished is not set, the active jobs get deleted right away to free up resources. However, when TTLSecondsAfterFinished is set, the active jobs and the completed jobs all get deleted after the TTL expires when the jobset itself gets deleted. We should always delete active jobs to free up resources when a jobset is failed or completed, then optionally cleanup the jobset itself if TTLSecondsAfterFinished is set.

Which issue(s) this PR fixes:

Fixes #666

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Delete active jobs right away when job finishes even when TTLSecondsAfterFinished is set

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 27, 2024
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Aug 27, 2024
Copy link

netlify bot commented Aug 27, 2024

Deploy Preview for kubernetes-sigs-jobset canceled.

Name Link
🔨 Latest commit 5c882f9
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-jobset/deploys/66ce3a5a6607b900083f5984

@@ -154,6 +154,10 @@ func (r *JobSetReconciler) reconcile(ctx context.Context, js *jobset.JobSet, upd

// If JobSet is already completed or failed, clean up active child jobs and requeue if TTLSecondsAfterFinished is set.
if jobSetFinished(js) {
if err := r.deleteJobs(ctx, ownedJobs.active); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this change makes sense, although I think we originally put deleteJobs after the TTL check because users wanted to use TTL to allow time to inspect logs via kubectl before everything is deleted, to debug more easily without having to craft queries in cloud logging systems.

Quickly freeing up resources that may still be being used by a completed/failed JobSet is important as well, but for this purpose the user can just tune their TTL accordingly.

@CecileRobertMichon @kannon92 @ahg-g any thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sgtm.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is only deleting active jobs, which I think makes sense.

/lgtm
/approve

@danielvegamyhre danielvegamyhre self-assigned this Aug 30, 2024
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ahg-g, CecileRobertMichon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 31, 2024
@k8s-ci-robot k8s-ci-robot merged commit 5b1c46f into kubernetes-sigs:main Aug 31, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Active jobs are not deleted when the job finishes if TTLSecondsAfterFinished is set
5 participants