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 { if template.Labels == nil {
template.Labels = make(map[string]string, 1) template.Labels = make(map[string]string, 1)
} }
// Use completion index annotation as label as well for consistency. template.Labels[batch.JobCompletionIndexLabel] = strconv.Itoa(index)
template.Labels[batch.JobCompletionIndexAnnotation] = strconv.Itoa(index)
} }
func podGenerateNameWithIndex(jobName string, index int) string { 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) { func checkJobCompletionLabel(t *testing.T, p *v1.PodTemplateSpec) {
t.Helper() t.Helper()
labels := p.GetLabels() labels := p.GetLabels()
if labels == nil || labels[batch.JobCompletionIndexAnnotation] == "" { if labels == nil || labels[batch.JobCompletionIndexLabel] == "" {
t.Errorf("missing expected pod label %s", batch.JobCompletionIndexAnnotation) t.Errorf("missing expected pod label %s", batch.JobCompletionIndexLabel)
} }
} }

View File

@ -28,6 +28,8 @@ const (
labelPrefix = "batch.kubernetes.io/" labelPrefix = "batch.kubernetes.io/"
JobCompletionIndexAnnotation = labelPrefix + "job-completion-index" 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 // JobTrackingFinalizer is a finalizer for Job's pods. It prevents them from
// being deleted before being accounted in the Job status. // being deleted before being accounted in the Job status.
// //