From c0d51a546508b69697c6ced6bac5c38db5c0175c Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Tue, 24 Sep 2024 17:03:52 -0700 Subject: [PATCH] Add labels to maintanance job pods Signed-off-by: Shubham Pampattiwar add changelog Signed-off-by: Shubham Pampattiwar --- changelogs/unreleased/8256-shubham-pampattiwar | 1 + pkg/repository/manager/manager.go | 3 +++ pkg/repository/manager/manager_test.go | 2 ++ 3 files changed, 6 insertions(+) create mode 100644 changelogs/unreleased/8256-shubham-pampattiwar 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]