diff --git a/pkg/controller/job/indexed_job_utils.go b/pkg/controller/job/indexed_job_utils.go index 3eb30bb7d63..9ec8f8535b2 100644 --- a/pkg/controller/job/indexed_job_utils.go +++ b/pkg/controller/job/indexed_job_utils.go @@ -315,8 +315,7 @@ func addCompletionIndexLabel(template *v1.PodTemplateSpec, index int) { if template.Labels == nil { template.Labels = make(map[string]string, 1) } - // Use completion index annotation as label as well for consistency. - template.Labels[batch.JobCompletionIndexAnnotation] = strconv.Itoa(index) + template.Labels[batch.JobCompletionIndexLabel] = strconv.Itoa(index) } func podGenerateNameWithIndex(jobName string, index int) string { diff --git a/pkg/controller/job/job_controller_test.go b/pkg/controller/job/job_controller_test.go index c9c147c6e41..e3b71aa68d9 100644 --- a/pkg/controller/job/job_controller_test.go +++ b/pkg/controller/job/job_controller_test.go @@ -4413,8 +4413,8 @@ func TestFinalizersRemovedExpectations(t *testing.T) { func checkJobCompletionLabel(t *testing.T, p *v1.PodTemplateSpec) { t.Helper() labels := p.GetLabels() - if labels == nil || labels[batch.JobCompletionIndexAnnotation] == "" { - t.Errorf("missing expected pod label %s", batch.JobCompletionIndexAnnotation) + if labels == nil || labels[batch.JobCompletionIndexLabel] == "" { + t.Errorf("missing expected pod label %s", batch.JobCompletionIndexLabel) } } diff --git a/staging/src/k8s.io/api/batch/v1/types.go b/staging/src/k8s.io/api/batch/v1/types.go index 22cf9ee9cb6..15cc874ff21 100644 --- a/staging/src/k8s.io/api/batch/v1/types.go +++ b/staging/src/k8s.io/api/batch/v1/types.go @@ -28,6 +28,8 @@ const ( labelPrefix = "batch.kubernetes.io/" JobCompletionIndexAnnotation = labelPrefix + "job-completion-index" + // JobCompletionIndexLabel is defined following the format .kubernetes.io/pod-index + JobCompletionIndexLabel = "job.kubernetes.io/pod-index" // JobTrackingFinalizer is a finalizer for Job's pods. It prevents them from // being deleted before being accounted in the Job status. //