From 3a6686f96c8b8cd19372a442e43e7106ea877388 Mon Sep 17 00:00:00 2001 From: MICHAEL S FRUCHTMAN Date: Thu, 19 Sep 2024 15:13:55 -0700 Subject: [PATCH] Add repo label to maintenance pod --- pkg/repository/manager/manager.go | 3 +++ pkg/repository/manager/manager_test.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/pkg/repository/manager/manager.go b/pkg/repository/manager/manager.go index cc4276b7303..a80d20c583a 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 ace4406c392..b18862a5e50 100644 --- a/pkg/repository/manager/manager_test.go +++ b/pkg/repository/manager/manager_test.go @@ -182,6 +182,9 @@ func TestBuildMaintenanceJob(t *testing.T) { assert.Equal(t, param.BackupRepo.Namespace, job.Namespace) assert.Equal(t, param.BackupRepo.Name, job.Labels[repository.RepositoryNameLabel]) + // check pod template spec + assert.Equal(t, param.BackupRepo.Name, job.Spec.Template.Labels[repository.RepositoryNameLabel]) + // Check container assert.Len(t, job.Spec.Template.Spec.Containers, 1) container := job.Spec.Template.Spec.Containers[0]