diff --git a/changelogs/unreleased/8256-shubham-pampattiwar b/changelogs/unreleased/8256-shubham-pampattiwar new file mode 100644 index 0000000000..961a06d336 --- /dev/null +++ b/changelogs/unreleased/8256-shubham-pampattiwar @@ -0,0 +1 @@ +Add labels to maintenance job pods \ No newline at end of file diff --git a/pkg/repository/manager/manager.go b/pkg/repository/manager/manager.go index cc4276b730..a80d20c583 100644 --- a/pkg/repository/manager/manager.go +++ b/pkg/repository/manager/manager.go @@ -418,6 +418,9 @@ func (m *manager) buildMaintenanceJob( Template: v1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Name: "velero-repo-maintenance-pod", + Labels: map[string]string{ + repository.RepositoryNameLabel: param.BackupRepo.Name, + }, }, Spec: v1.PodSpec{ Containers: []v1.Container{ diff --git a/pkg/repository/manager/manager_test.go b/pkg/repository/manager/manager_test.go index ace4406c39..0a798120ba 100644 --- a/pkg/repository/manager/manager_test.go +++ b/pkg/repository/manager/manager_test.go @@ -182,6 +182,8 @@ func TestBuildMaintenanceJob(t *testing.T) { assert.Equal(t, param.BackupRepo.Namespace, job.Namespace) assert.Equal(t, param.BackupRepo.Name, job.Labels[repository.RepositoryNameLabel]) + assert.Equal(t, param.BackupRepo.Name, job.Spec.Template.ObjectMeta.Labels[repository.RepositoryNameLabel]) + // Check container assert.Len(t, job.Spec.Template.Spec.Containers, 1) container := job.Spec.Template.Spec.Containers[0]