update name of pod index label

This commit is contained in:
Daniel Vega-Myhre 2023-07-10 18:19:47 +00:00
parent ecf0cee91c
commit 98c6e25c37
3 changed files with 5 additions and 4 deletions

View File

@ -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 {

View File

@ -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)
}
}

View File

@ -28,6 +28,8 @@ const (
labelPrefix = "batch.kubernetes.io/"
JobCompletionIndexAnnotation = labelPrefix + "job-completion-index"
// JobCompletionIndexLabel is defined following the format <controller>.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.
//