Merge pull request #8812 from Lyndon-Li/third-party-annotation-for-maintenance-job
Run the E2E test on kind / build (push) Failing after 6m4s
Run the E2E test on kind / setup-test-matrix (push) Successful in 2s
Run the E2E test on kind / run-e2e-test (push) Has been skipped
Main CI / Build (push) Failing after 37s
Close stale issues and PRs / stale (push) Successful in 8s
Trivy Nightly Scan / Trivy nightly scan (velero, main) (push) Failing after 1m11s
Trivy Nightly Scan / Trivy nightly scan (velero-restore-helper, main) (push) Failing after 55s

Add third party annotation support for maintenance job
This commit is contained in:
lyndon-li
2025-03-26 17:08:03 +08:00
committed by GitHub
3 changed files with 20 additions and 2 deletions
+1
View File
@@ -0,0 +1 @@
Add third party annotation support for maintenance job, so that the declared third party annotations could be added to the maintenance job pods
+10 -2
View File
@@ -460,6 +460,13 @@ func buildJob(cli client.Client, ctx context.Context, repo *velerov1api.BackupRe
}
}
podAnnotations := map[string]string{}
for _, k := range util.ThirdPartyAnnotations {
if v := veleroutil.GetVeleroServerAnnotationValue(deployment, k); v != "" {
podAnnotations[k] = v
}
}
// Set arguments
args := []string{"repo-maintenance"}
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
BackoffLimit: new(int32), // Never retry
Template: v1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Name: "velero-repo-maintenance-pod",
Labels: podLabels,
Name: "velero-repo-maintenance-pod",
Labels: podLabels,
Annotations: podAnnotations,
},
Spec: v1.PodSpec{
Containers: []v1.Container{
+9
View File
@@ -96,3 +96,12 @@ func GetVeleroServerLabelValue(deployment *appsv1.Deployment, key string) string
return deployment.Spec.Template.Labels[key]
}
// GetVeleroServerAnnotationValue returns the value of specified annotation of Velero server deployment
func GetVeleroServerAnnotationValue(deployment *appsv1.Deployment, key string) string {
if deployment.Spec.Template.Annotations == nil {
return ""
}
return deployment.Spec.Template.Annotations[key]
}