Skip to content

Commit 7823232

Browse files
Add GA and deprecation notes to JobTrackingWithFinalizers
1 parent c796398 commit 7823232

File tree

3 files changed

+147
-45
lines changed

3 files changed

+147
-45
lines changed

keps/prod-readiness/sig-apps/2307.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ alpha:
33
approver: "@wojtek-t"
44
beta:
55
approver: "@wojtek-t"
6+
stable:
7+
approver: "@wojtek-t"

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

Lines changed: 139 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,19 @@
1919
- [Deleted Pods](#deleted-pods)
2020
- [Deleted Jobs](#deleted-jobs)
2121
- [Pod adoption](#pod-adoption)
22+
- [Monitoring Pods with finalizers](#monitoring-pods-with-finalizers)
23+
- [Migrating Jobs with legacy tracking](#migrating-jobs-with-legacy-tracking)
2224
- [Test Plan](#test-plan)
25+
- [Prerequisite testing updates](#prerequisite-testing-updates)
26+
- [Unit tests](#unit-tests)
27+
- [Integration tests](#integration-tests)
28+
- [E2E test:](#e2e-test)
29+
- [Load test:](#load-test)
2330
- [Graduation Criteria](#graduation-criteria)
2431
- [Alpha](#alpha)
2532
- [Alpha -> Beta Graduation](#alpha---beta-graduation)
2633
- [Beta -> GA Graduation](#beta---ga-graduation)
34+
- [Deprecation](#deprecation)
2735
- [Upgrade / Downgrade Strategy](#upgrade--downgrade-strategy)
2836
- [Version Skew Strategy](#version-skew-strategy)
2937
- [Production Readiness Review Questionnaire](#production-readiness-review-questionnaire)
@@ -68,8 +76,12 @@ Items marked with (R) are required *prior to targeting to a milestone / release*
6876
- [x] (R) Enhancement issue in release milestone, which links to KEP dir in [kubernetes/enhancements] (not the initial KEP PR)
6977
- [x] (R) KEP approvers have approved the KEP status as `implementable`
7078
- [x] (R) Design details are appropriately documented
71-
- [x] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input
79+
- [x] (R) Test plan is in place, giving consideration to SIG Architecture and SIG Testing input (including test refactors)
80+
- [x] e2e Tests for all Beta API Operations (endpoints)
81+
- [x] (R) Ensure GA e2e tests meet requirements for [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
82+
- [x] (R) Minimum Two Week Window for GA e2e tests to prove flake free
7283
- [x] (R) Graduation criteria is in place
84+
- [x] (R) [all GA Endpoints](https://github.com/kubernetes/community/pull/1806) must be hit by [Conformance Tests](https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/conformance-tests.md)
7385
- [x] (R) Production readiness review completed
7486
- [x] (R) Production readiness review approved
7587
- [ ] "Implementation History" section is up-to-date for milestone
@@ -307,21 +319,89 @@ finalizer.
307319
The job controller adds the finalizer in the same patch request that modifies
308320
the owner reference.
309321

322+
## Monitoring Pods with finalizers
323+
324+
Starting in 1.26, the metric `job_pod_tracking_finalizer` is a gauge that
325+
tracks the number of pods that currently have a job tracking finalizer.
326+
327+
The metric increments when the job controller observes a pod created or adopted,
328+
and decrements when the job controller observes an update that removes the
329+
finalizer or a pod deletion.
330+
331+
## Migrating Jobs with legacy tracking
332+
333+
Starting in 1.26, when the feature gate `MigrateJobLegacyTracking` is enabled,
334+
the job controller migrates jobs with legacy tracking to tracking with finalizers.
335+
336+
If a Job doesn't have the annotation `batch.kubernetes.io/job-completion`, it
337+
means that is not currently tracked with finalizers. The job controller starts
338+
the following migration process:
339+
1. Add the finalizer `batch.kubernetes.io/job-completion` to all pods with
340+
`.status.phase=(Pending/Running)`.
341+
2. Ignore pods with `.status.phase=(Complete/Failed)` that don't have the `batch.kubernetes.io/job-completion`.
342+
They are considered to be already counted in `.status.(failed/succeeded)`.
343+
3. Add the annotation `batch.kubernetes.io/job-completion`.
344+
345+
This might lead to extra pods being created, but this is acceptable because:
346+
347+
- After the `JobTrackingWithFinalizers` feature was enabled for some time, the
348+
Job controller is already tracking most Jobs using finalizers.
349+
- For the remaining Jobs, the Job controller already accounted most of the
350+
finished Pods in the status. The controller might leave some
351+
finished Pods unaccounted, if they finish before the controller has a chance
352+
to add a finalizer. This situation is no worse that the legacy tracking
353+
were the controller doesn't account for Pods removed by garbage collection or
354+
other means.
355+
310356
### Test Plan
311357

312-
- Unit tests:
358+
[x] I/we understand the owners of the involved components may require updates to
359+
existing tests to make this code solid enough prior to committing the changes necessary
360+
to implement this enhancement.
361+
362+
##### Prerequisite testing updates
363+
364+
Already fulfilled at alpha and beta stages.
365+
366+
##### Unit tests
367+
313368
- Job sync with feature gate enabled.
314369
- Removal of finalizers when feature gate is disabled.
315-
- Tracking of terminating Pods.
316-
- Integration tests:
317-
- Job tracking with feature enabled.
318-
- Tracking of terminating Pods.
319-
- Transition from feature enabled to disabled and enabled again.
320-
- Clean up finalizers of Orphan Pods.
370+
- Tracking of terminating Pods for NonIndexed and Indexed Jobs.
371+
372+
Coverage:
373+
374+
- `pkg/controller/job`: 2022-08-06 - 90%
375+
- `pkg/apis/batch/validation`: 2022-08-06 - 96%
376+
- `pkg/apis/batch/v1`: 2022-08-06 - 85.2%
377+
- `pkg/registry/batch/job`: 2022-08-06 - 79.7%
378+
379+
##### Integration tests
380+
381+
Almost the entire [test suite](https://storage.googleapis.com/k8s-triage/index.html?job=ci-kubernetes-integration&test=test%2Fintegration%2Fjob) runs with finalizers.
382+
383+
- Job tracking with feature enabled: `TestNonParallelJob`, `TestParallelJob`, `TestParallelJobParallelism`, `TestIndexedJob`, `TestJobFailedWithInterrupts`.
384+
- Transition from feature enabled to disabled and enabled again: `TestDisableJobTrackingWithFinalizers`.
385+
- Clean up finalizers of Orphan Pods `TestOrphanPodsFinalizersClearedWithGC`
321386
- Tracking Jobs with big number of Pods, making sure the status is eventually
322-
consistent.
323-
- E2E test:
324-
- Job tracking with feature enabled.
387+
consistent (`TestParallelJobWithCompletions`, `TestFinalizersClearedWhenBackoffLimitExceeded`)
388+
389+
Exceptions:
390+
391+
- Test orphan pods are cleared when TrackingWithFinalizers is disabled: `TestOrphanPodsFinalizersClearedWithFeatureDisabled`.
392+
- Test suspend jobs (finalizers to be enabled).
393+
- Test mutable scheduling directives (finalizers to be enabled).
394+
395+
##### E2E test:
396+
397+
[Every E2E](https://testgrid.k8s.io/sig-testing-canaries#ci-kubernetes-coverage-e2e-gci-gce&width=20&include-filter-by-regex=%5C%5Bsig-apps%5C%5D%20Job)
398+
test is affected. The feature didn't require new tests, as it doesn't add
399+
new endpoints or new functionality.
400+
401+
##### Load test:
402+
403+
A [clusterloader2 test](https://github.com/kubernetes/perf-tests/blob/master/clusterloader2/testing/batch/config.yaml)
404+
for jobs with multiple sizes.
325405

326406
### Graduation Criteria
327407

@@ -346,21 +426,32 @@ the owner reference.
346426

347427
#### Beta -> GA Graduation
348428

349-
- Remove legacy tracking and the use of `batch.kubernetes.io/job-completion` as
350-
an annotation. This is possible assuming:
351-
- After the feature was enabled for some time, the Job controller is already
352-
tracking most Jobs using finalizers.
353-
- For the remaining Jobs, the Job controller already accounted most of the
354-
finished Pods in the status. The controller adds a tracking finalizer to
355-
any running Pod that doesn't have it. The controller might leave some
356-
finished Pods unaccounted, if they finish before the controller has a chance
357-
to add a finalizer. This is acceptable as it's no worse that the current
358-
behavior were the controller doesn't account for Pods removed by garbage
359-
collection or other means.
429+
- [Migrate existing Jobs to tracking with finalizers](#migrating-jobs-with-legacy-tracking)
430+
under feature gate `MigrateJobLegacyTracking`, disabled by default.
360431
- Job E2E tests graduate to conformance.
361432
- Job tracking scales to 10^5 completions per Job processed within an order of
362433
minutes.
363434

435+
#### Deprecation
436+
437+
In 1.26:
438+
439+
- Declare deprecation of annotation `batch.kubernetes.io/job-completion` in
440+
[documentation](https://kubernetes.io/docs/reference/labels-annotations-taints/#batch-kubernetes-io-job-tracking).
441+
- Lock `JobTrackingWithFinalizers` to true.
442+
443+
In 1.27:
444+
445+
- Lock `MigrateJobLegacyTracking` to true.
446+
- Remove legacy tracking code.
447+
448+
In 1.28:
449+
450+
- Stop adding annotation `batch.kubernetes.io/job-completion` and remove from
451+
documentation.
452+
- Remove feature gates `JobTrackingWithFinalizers` and `MigrateJobLegacyTracking`.
453+
- Remove legacy to finalizers migration code.
454+
364455
### Upgrade / Downgrade Strategy
365456

366457
When the feature `JobTrackingWithFinalizers` is enabled for the first
@@ -448,6 +539,7 @@ No implications to node runtime.
448539
duration than previous versions of the job controller due to the new API
449540
calls.
450541
- Stale `job_sync_total` or `job_finished_total`.
542+
- The metric `job_pod_tracking_finalizer` doesn't decrease when pods finish.
451543

452544
#### Were upgrade and rollback tested? Was the upgrade->downgrade->upgrade path tested?
453545

@@ -472,7 +564,7 @@ The flow was completed successfully with all the stated verifications.
472564

473565
#### Is the rollout accompanied by any deprecations and/or removals of features, APIs, fields of API types, flags, etc.?
474566

475-
No.
567+
Yes, see [Deprecation](#deprecation) for the full plan.
476568

477569
### Monitoring Requirements
478570

@@ -504,14 +596,17 @@ The flow was completed successfully with all the stated verifications.
504596

505597
- [x] Metrics
506598
- Metric name: `job_sync_duration_seconds`
507-
- [Optional] Aggregation method:
508-
- Components exposing the metric: `kube-controller-manager`
599+
- [Optional] Aggregation method:
600+
- Components exposing the metric: `kube-controller-manager`
601+
- Metric name: `job_pod_tracking_finalizer`
602+
- [Optional] Aggregation method:
603+
- Components exposing the metric: `kube-controller-manager`
509604

510605
#### Are there any missing metrics that would be useful to have to improve observability of this feature?
511606

512-
- A label in `job_sync_total` for the type of Job tracking. This label would
513-
have to be removed when we graduate the feature to GA, adding operational
514-
burden.
607+
- A label in `job_sync_total` for the type of Job tracking. We decided not to
608+
add this label because it would have to be removed on GA graduation, adding
609+
operational burden.
515610

516611
### Dependencies
517612

@@ -570,20 +665,21 @@ The flow was completed successfully with all the stated verifications.
570665

571666
#### What are other known failure modes?
572667

573-
TBD from user feedback. No know failures modes so far.
574-
575-
<!--
576-
For each of them, fill in the following information by copying the below template:
577-
- [Failure mode brief description]
578-
- Detection: How can it be detected via metrics? Stated another way:
579-
how can an operator troubleshoot without logging into a master or worker node?
580-
- Mitigations: What can be done to stop the bleeding, especially for already
581-
running user workloads?
582-
- Diagnostics: What are the useful log messages and their required logging
583-
levels that could help debug the issue?
584-
Not required until feature graduated to beta.
585-
- Testing: Are there any tests for failure mode? If not, describe why.
586-
-->
668+
- Terminated pods are stuck with finalizers
669+
- Detection:
670+
- Before 1.26: Observe the behavior in pods.
671+
- After 1.26: Based on metric `job_pod_tracking_finalizer`
672+
- Mitigations:
673+
Before 1.26, disable `JobTrackingWithFinalizers`.
674+
- Diagnostics:
675+
The job controller reports errors updating the Job status and/or patching
676+
Pods.
677+
There were some bugs that would cause this (examples:
678+
[#109485](https://github.com/kubernetes/kubernetes/issues/109485),
679+
[#111646](https://github.com/kubernetes/kubernetes/pull/111646)).
680+
In newer versions, this can still happen if there is a buggy webhook
681+
that prevents pod updates to remove finalizers.
682+
- Testing: Discovered bugs are covered by unit and integration tests.
587683

588684
#### What steps should be taken if SLOs are not being met to determine the problem?
589685

@@ -608,6 +704,7 @@ The flow was completed successfully with all the stated verifications.
608704
- 2021-08-18: PRR completed and graduation to beta proposed.
609705
- 2021-10-14: Added details for Upgrade->Downgrade->Upgrade manual test.
610706
- 2021-10-21: Add link to testgrid.
707+
- 2022-08-29: Add GA and deprecation notes.
611708

612709
## Drawbacks
613710

keps/sig-apps/2307-job-tracking-without-lingering-pods/kep.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ stage: beta
2020
# The most recent milestone for which work toward delivery of this KEP has been
2121
# done. This can be the current (upcoming) milestone, if it is being actively
2222
# worked on.
23-
latest-milestone: "v1.23"
23+
latest-milestone: "v1.26"
2424

2525
# The milestone at which this feature was, or is targeted to be, at each stage.
2626
milestone:
2727
alpha: "v1.22"
2828
beta: "v1.23"
29-
stable: "v1.25"
29+
stable: "v1.26"
3030

3131
# The following PRR answers are required at alpha release
3232
# List the feature gate name and the components for which it must be enabled
@@ -35,7 +35,10 @@ feature-gates:
3535
components:
3636
- kube-apiserver
3737
- kube-controller-manager
38-
disable-supported: true
38+
- name: MigrateJobLegacyTracking
39+
components:
40+
- kube-controller-manager
41+
disable-supported: false
3942

4043
# The following PRR answers are required at beta release
4144
metrics:

0 commit comments

Comments
 (0)