Skip to content

Commit 751d782

Browse files
authored
Merge pull request #8812 from Lyndon-Li/third-party-annotation-for-maintenance-job
Add third party annotation support for maintenance job
2 parents 883e3e4 + f1dcb7b commit 751d782

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add third party annotation support for maintenance job, so that the declared third party annotations could be added to the maintenance job pods

pkg/repository/maintenance/maintenance.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,13 @@ func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRe
460460
}
461461
}
462462

463+
podAnnotations := map[string]string{}
464+
for _, k := range util.ThirdPartyAnnotations {
465+
if v := veleroutil.GetVeleroServerAnnotationValue(deployment, k); v != "" {
466+
podAnnotations[k] = v
467+
}
468+
}
469+
463470
// Set arguments
464471
args := []string{"repo-maintenance"}
465472
args = append(args, fmt.Sprintf("--repo-name=%s", repo.Spec.VolumeNamespace))
@@ -481,8 +488,9 @@ func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRe
481488
BackoffLimit: new(int32), // Never retry
482489
Template: v1.PodTemplateSpec{
483490
ObjectMeta: metav1.ObjectMeta{
484-
Name: "velero-repo-maintenance-pod",
485-
Labels: podLabels,
491+
Name: "velero-repo-maintenance-pod",
492+
Labels: podLabels,
493+
Annotations: podAnnotations,
486494
},
487495
Spec: v1.PodSpec{
488496
Containers: []v1.Container{

pkg/util/velero/velero.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,12 @@ func GetVeleroServerLabelValue(deployment *appsv1.Deployment, key string) string
9696

9797
return deployment.Spec.Template.Labels[key]
9898
}
99+
100+
// GetVeleroServerAnnotationValue returns the value of specified annotation of Velero server deployment
101+
func GetVeleroServerAnnotationValue(deployment *appsv1.Deployment, key string) string {
102+
if deployment.Spec.Template.Annotations == nil {
103+
return ""
104+
}
105+
106+
return deployment.Spec.Template.Annotations[key]
107+
}

0 commit comments

Comments
 (0)