Skip to content

Commit b98d253

Browse files
authored
Merge pull request kubernetes#2776 from alculquicondor/job-tracking
Add Job finalizer on creation strategy
2 parents 9c66a13 + 187b2f6 commit b98d253

File tree

1 file changed

+16
-12
lines changed
  • keps/sig-apps/2307-job-tracking-without-lingering-pods

1 file changed

+16
-12
lines changed

keps/sig-apps/2307-job-tracking-without-lingering-pods/README.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ type JobStatus struct {
153153

154154
// UncountedTerminatedPods holds UIDs of Pods that have finished but
155155
// haven't been accounted in the counters.
156-
// If nil, Job tracking doesn't make use of this structure.
156+
// Old jobs might not be tracked using this field, in which case this
157+
// field remains null.
157158
// +optional
158159
UncountedTerminatedPods *UncountedTerminatedPods
159160
}
@@ -179,8 +180,8 @@ could be stopped at any point and executed again from the first step without
179180
losing information. Generally, all the steps happen in a single Job sync
180181
cycle.
181182

182-
0. The Job controller adds a the `batch.kubernetes.io/job-completion` finalizer
183-
to the Job.
183+
0. kube-apiserver adds the `batch.kubernetes.io/job-completion` finalizer
184+
to newly created Jobs.
184185
1. The Job controller calculates the number of succeeded Pods as the sum of:
185186
- `.status.succeeded`,
186187
- the size of `job.status.uncountedTerminatedPods.succeeded` and
@@ -329,19 +330,22 @@ time, the cluster can have Jobs whose Pods don't have the
329330
`batch.kubernetes.io/job-completion` finalizer. It would be hard to add the
330331
finalizer to all Pods while preventing race conditions.
331332

332-
We use `.status.uncountedTerminatedPods != nil` to indicate whether the Job
333-
was created after the feature was enabled. If this field is nil, the Job
334-
controller tracks Pods using the legacy tracking.
333+
The job controller uses the existence of the finalizer
334+
`batch.kubernetes.io/job-completion` to determine if it should use tracking with
335+
finalizers. If the finalizer is not present, and the Job is not yet completed,
336+
the job controllers tracks Pods using the legacy tracking (with lingering Pods).
335337

336-
The kube-apiserver sets `.status.uncountedTerminatedPods` to an empty struct
337-
when the feature gate `JobTrackingWithFinalizers` is enabled, at Job
338-
creation.
338+
The kube-apiserver sets the `batch.kubernetes.io/job-completion` finalizer to
339+
newly created Jobs when the feature gate `JobTrackingWithFinalizers` is enabled.
339340

340341
When the feature is disabled after being enabled for some time, the next time
341342
the Job controller syncs a Job:
342-
1. It removes finalizers from all Pods owned by the Job.
343+
1. It removes finalizers from the Job and all the Pods owned by it.
343344
2. Sets `.status.uncountedTerminatedPods` to nil.
344345

346+
After this point, the Job will no longer be tracked using finalizers, even if
347+
the feature gate is re-enabled.
348+
345349
### Version Skew Strategy
346350

347351
No implications to node runtime.
@@ -476,8 +480,8 @@ previous answers based on experience in the field._
476480
- estimated throughput: one per Pod created by the Job controller, when Pod
477481
finishes or is removed.
478482
- originating component: kube-controller-manager
479-
- PATCH Jobs, to add and remove finalizers.
480-
- estimated throughput: two calls for each Job created.
483+
- PATCH Jobs, to remove finalizers.
484+
- estimated throughput: one call for each Job created.
481485
- originating component: kube-controller-manager
482486
- PUT Job status, to keep track of uncounted Pods.
483487
- estimated throughput: at least one per Job sync. The job controller

0 commit comments

Comments
 (0)