diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 77e2b100745..02c4e06f113 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -4380,7 +4380,7 @@ "type": "integer" }, "completionMode": { - "description": "CompletionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5.\n\nThis field is alpha-level and is only honored by servers that enable the IndexedJob feature gate. More completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, the controller skips updates for the Job.", + "description": "CompletionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5. In addition, The Pod name takes the form `$(job-name)-$(index)-$(random-string)`, the Pod hostname takes the form `$(job-name)-$(index)`.\n\nThis field is beta-level. More completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, the controller skips updates for the Job.", "type": "string" }, "completions": { diff --git a/pkg/apis/batch/types.go b/pkg/apis/batch/types.go index 29a49f9e0d3..77d5b6f281a 100644 --- a/pkg/apis/batch/types.go +++ b/pkg/apis/batch/types.go @@ -183,9 +183,11 @@ type JobSpec struct { // for each index. // When value is `Indexed`, .spec.completions must be specified and // `.spec.parallelism` must be less than or equal to 10^5. + // In addition, The Pod name takes the form + // `$(job-name)-$(index)-$(random-string)`, + // the Pod hostname takes the form `$(job-name)-$(index)`. // - // This field is alpha-level and is only honored by servers that enable the - // IndexedJob feature gate. More completion modes can be added in the future. + // This field is beta-level. More completion modes can be added in the future. // If the Job controller observes a mode that it doesn't recognize, the // controller skips updates for the Job. // +optional diff --git a/pkg/controller/job/indexed_job_utils.go b/pkg/controller/job/indexed_job_utils.go index 9f9a09ac51b..601650e22c0 100644 --- a/pkg/controller/job/indexed_job_utils.go +++ b/pkg/controller/job/indexed_job_utils.go @@ -160,7 +160,7 @@ func getCompletionIndex(annotations map[string]string) int { if annotations == nil { return unknownCompletionIndex } - v, ok := annotations[batch.JobCompletionIndexAnnotationAlpha] + v, ok := annotations[batch.JobCompletionIndexAnnotation] if !ok { return unknownCompletionIndex } @@ -193,7 +193,7 @@ func addCompletionIndexEnvVariable(container *v1.Container) { Name: completionIndexEnvName, ValueFrom: &v1.EnvVarSource{ FieldRef: &v1.ObjectFieldSelector{ - FieldPath: fmt.Sprintf("metadata.annotations['%s']", batch.JobCompletionIndexAnnotationAlpha), + FieldPath: fmt.Sprintf("metadata.annotations['%s']", batch.JobCompletionIndexAnnotation), }, }, }) @@ -203,7 +203,7 @@ func addCompletionIndexAnnotation(template *v1.PodTemplateSpec, index int) { if template.Annotations == nil { template.Annotations = make(map[string]string, 1) } - template.Annotations[batch.JobCompletionIndexAnnotationAlpha] = strconv.Itoa(index) + template.Annotations[batch.JobCompletionIndexAnnotation] = strconv.Itoa(index) } type byCompletionIndex []*v1.Pod diff --git a/pkg/controller/job/indexed_job_utils_test.go b/pkg/controller/job/indexed_job_utils_test.go index cdb79c03239..1589b67ae03 100644 --- a/pkg/controller/job/indexed_job_utils_test.go +++ b/pkg/controller/job/indexed_job_utils_test.go @@ -249,7 +249,7 @@ func hollowPodsWithIndexPhase(descs []indexPhase) []*v1.Pod { } if desc.Index != noIndex { p.Annotations = map[string]string{ - batch.JobCompletionIndexAnnotationAlpha: desc.Index, + batch.JobCompletionIndexAnnotation: desc.Index, } } pods = append(pods, p) @@ -267,7 +267,7 @@ func toIndexPhases(pods []*v1.Pod) []indexPhase { for i, p := range pods { index := noIndex if p.Annotations != nil { - index = p.Annotations[batch.JobCompletionIndexAnnotationAlpha] + index = p.Annotations[batch.JobCompletionIndexAnnotation] } result[i] = indexPhase{index, p.Status.Phase} } diff --git a/pkg/controller/job/job_controller_test.go b/pkg/controller/job/job_controller_test.go index 746e766b075..1760c714be9 100644 --- a/pkg/controller/job/job_controller_test.go +++ b/pkg/controller/job/job_controller_test.go @@ -149,7 +149,7 @@ func setPodsStatusesWithIndexes(podIndexer cache.Indexer, job *batch.Job, status p.Status = v1.PodStatus{Phase: s.Phase} if s.Index != noIndex { p.Annotations = map[string]string{ - batch.JobCompletionIndexAnnotationAlpha: s.Index, + batch.JobCompletionIndexAnnotation: s.Index, } } podIndexer.Add(p) @@ -2151,7 +2151,7 @@ func checkJobCompletionEnvVariable(t *testing.T, spec *v1.PodSpec) { Name: "JOB_COMPLETION_INDEX", ValueFrom: &v1.EnvVarSource{ FieldRef: &v1.ObjectFieldSelector{ - FieldPath: fmt.Sprintf("metadata.annotations['%s']", batch.JobCompletionIndexAnnotationAlpha), + FieldPath: fmt.Sprintf("metadata.annotations['%s']", batch.JobCompletionIndexAnnotation), }, }, }, diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index 2751253a462..03e44daab4f 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -316,6 +316,7 @@ const ( // owner: @alculquicondor // alpha: v1.21 + // beta: v1.22 // // Allows Job controller to manage Pod completions per completion index. IndexedJob featuregate.Feature = "IndexedJob" @@ -820,7 +821,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS VolumeSnapshotDataSource: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.21 ProcMountType: {Default: false, PreRelease: featuregate.Alpha}, TTLAfterFinished: {Default: true, PreRelease: featuregate.Beta}, - IndexedJob: {Default: false, PreRelease: featuregate.Alpha}, + IndexedJob: {Default: true, PreRelease: featuregate.Beta}, KubeletPodResources: {Default: true, PreRelease: featuregate.Beta}, LocalStorageCapacityIsolationFSQuotaMonitoring: {Default: false, PreRelease: featuregate.Alpha}, NonPreemptingPriority: {Default: true, PreRelease: featuregate.Beta}, diff --git a/staging/src/k8s.io/api/batch/v1/generated.proto b/staging/src/k8s.io/api/batch/v1/generated.proto index 04f0e7ea7e6..c786d6ae25c 100644 --- a/staging/src/k8s.io/api/batch/v1/generated.proto +++ b/staging/src/k8s.io/api/batch/v1/generated.proto @@ -246,9 +246,11 @@ message JobSpec { // for each index. // When value is `Indexed`, .spec.completions must be specified and // `.spec.parallelism` must be less than or equal to 10^5. + // In addition, The Pod name takes the form + // `$(job-name)-$(index)-$(random-string)`, + // the Pod hostname takes the form `$(job-name)-$(index)`. // - // This field is alpha-level and is only honored by servers that enable the - // IndexedJob feature gate. More completion modes can be added in the future. + // This field is beta-level. More completion modes can be added in the future. // If the Job controller observes a mode that it doesn't recognize, the // controller skips updates for the Job. // +optional diff --git a/staging/src/k8s.io/api/batch/v1/types.go b/staging/src/k8s.io/api/batch/v1/types.go index 12f4b04cbd9..caf0374c174 100644 --- a/staging/src/k8s.io/api/batch/v1/types.go +++ b/staging/src/k8s.io/api/batch/v1/types.go @@ -21,7 +21,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -const JobCompletionIndexAnnotationAlpha = "batch.kubernetes.io/job-completion-index" +const JobCompletionIndexAnnotation = "batch.kubernetes.io/job-completion-index" // +genclient // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object @@ -162,9 +162,11 @@ type JobSpec struct { // for each index. // When value is `Indexed`, .spec.completions must be specified and // `.spec.parallelism` must be less than or equal to 10^5. + // In addition, The Pod name takes the form + // `$(job-name)-$(index)-$(random-string)`, + // the Pod hostname takes the form `$(job-name)-$(index)`. // - // This field is alpha-level and is only honored by servers that enable the - // IndexedJob feature gate. More completion modes can be added in the future. + // This field is beta-level. More completion modes can be added in the future. // If the Job controller observes a mode that it doesn't recognize, the // controller skips updates for the Job. // +optional diff --git a/staging/src/k8s.io/api/batch/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/batch/v1/types_swagger_doc_generated.go index d98c5edeb1e..f522b01a117 100644 --- a/staging/src/k8s.io/api/batch/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/batch/v1/types_swagger_doc_generated.go @@ -119,7 +119,7 @@ var map_JobSpec = map[string]string{ "manualSelector": "manualSelector controls generation of pod labels and pod selectors. Leave `manualSelector` unset unless you are certain what you are doing. When false or unset, the system pick labels unique to this job and appends those labels to the pod template. When true, the user is responsible for picking unique labels and specifying the selector. Failure to pick a unique label may cause this and other jobs to not function correctly. However, You may see `manualSelector=true` in jobs that were created with the old `extensions/v1beta1` API. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/#specifying-your-own-pod-selector", "template": "Describes the pod that will be created when executing a job. More info: https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/", "ttlSecondsAfterFinished": "ttlSecondsAfterFinished limits the lifetime of a Job that has finished execution (either Complete or Failed). If this field is set, ttlSecondsAfterFinished after the Job finishes, it is eligible to be automatically deleted. When the Job is being deleted, its lifecycle guarantees (e.g. finalizers) will be honored. If this field is unset, the Job won't be automatically deleted. If this field is set to zero, the Job becomes eligible to be deleted immediately after it finishes. This field is alpha-level and is only honored by servers that enable the TTLAfterFinished feature.", - "completionMode": "CompletionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5.\n\nThis field is alpha-level and is only honored by servers that enable the IndexedJob feature gate. More completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, the controller skips updates for the Job.", + "completionMode": "CompletionMode specifies how Pod completions are tracked. It can be `NonIndexed` (default) or `Indexed`.\n\n`NonIndexed` means that the Job is considered complete when there have been .spec.completions successfully completed Pods. Each Pod completion is homologous to each other.\n\n`Indexed` means that the Pods of a Job get an associated completion index from 0 to (.spec.completions - 1), available in the annotation batch.kubernetes.io/job-completion-index. The Job is considered complete when there is one successfully completed Pod for each index. When value is `Indexed`, .spec.completions must be specified and `.spec.parallelism` must be less than or equal to 10^5. In addition, The Pod name takes the form `$(job-name)-$(index)-$(random-string)`, the Pod hostname takes the form `$(job-name)-$(index)`.\n\nThis field is beta-level. More completion modes can be added in the future. If the Job controller observes a mode that it doesn't recognize, the controller skips updates for the Job.", "suspend": "Suspend specifies whether the Job controller should create Pods or not. If a Job is created with suspend set to true, no Pods are created by the Job controller. If a Job is suspended after creation (i.e. the flag goes from false to true), the Job controller will delete all active Pods associated with this Job. Users must design their workload to gracefully handle this. Suspending a Job will reset the StartTime field of the Job, effectively resetting the ActiveDeadlineSeconds timer too. This is an alpha field and requires the SuspendJob feature gate to be enabled; otherwise this field may not be set to true. Defaults to false.", } diff --git a/test/e2e/apps/job.go b/test/e2e/apps/job.go index d5468945bfb..eaeb740d4f9 100644 --- a/test/e2e/apps/job.go +++ b/test/e2e/apps/job.go @@ -171,7 +171,7 @@ var _ = SIGDescribe("Job", func() { succeededIndexes := sets.NewInt() for _, pod := range pods.Items { if pod.Status.Phase == v1.PodSucceeded && pod.Annotations != nil { - ix, err := strconv.Atoi(pod.Annotations[batchv1.JobCompletionIndexAnnotationAlpha]) + ix, err := strconv.Atoi(pod.Annotations[batchv1.JobCompletionIndexAnnotation]) framework.ExpectNoError(err, "failed obtaining completion index from pod in namespace: %s", f.Namespace.Name) succeededIndexes.Insert(ix) } diff --git a/test/integration/job/job_test.go b/test/integration/job/job_test.go index 96db8b1402c..69c710d11b3 100644 --- a/test/integration/job/job_test.go +++ b/test/integration/job/job_test.go @@ -569,9 +569,9 @@ func getCompletionIndex(p *v1.Pod) (int, error) { if p.Annotations == nil { return 0, errors.New("no annotations found") } - v, ok := p.Annotations[batchv1.JobCompletionIndexAnnotationAlpha] + v, ok := p.Annotations[batchv1.JobCompletionIndexAnnotation] if !ok { - return 0, fmt.Errorf("annotation %s not found", batchv1.JobCompletionIndexAnnotationAlpha) + return 0, fmt.Errorf("annotation %s not found", batchv1.JobCompletionIndexAnnotation) } return strconv.Atoi(v) }