Skip to content

Commit ed43fda

Browse files
kubeobjects: exclude ramen objects from velero backup
When we create a backup request, we add a match expression that excludes the resources created by ramen. This way we don't have to ask the users to exclude ramen resources explicitly in their recipes. Signed-off-by: Raghavendra Talur <[email protected]> Co-Authored-by: Abhijeet Shakya <[email protected]>
1 parent 433d89a commit ed43fda

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

internal/controller/kubeobjects/velero/requests.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,14 +373,28 @@ func backupRealCreate(
373373
}
374374

375375
func getBackupSpecFromObjectsSpec(objectsSpec kubeobjects.Spec) velero.BackupSpec {
376+
if objectsSpec.LabelSelector == nil {
377+
objectsSpec.LabelSelector = &metav1.LabelSelector{}
378+
}
379+
380+
newLabelSelector := objectsSpec.LabelSelector
381+
newLabelSelector.MatchExpressions = append(
382+
newLabelSelector.MatchExpressions,
383+
metav1.LabelSelectorRequirement{
384+
Key: util.CreatedByRamenLabel,
385+
Operator: metav1.LabelSelectorOpNotIn,
386+
Values: []string{"true"},
387+
},
388+
)
389+
376390
return velero.BackupSpec{
377391
IncludedNamespaces: objectsSpec.IncludedNamespaces,
378392
IncludedResources: objectsSpec.IncludedResources,
379393
// exclude VRs from Backup so VRG can create them: see https://github.com/RamenDR/ramen/issues/884
380394
ExcludedResources: append(objectsSpec.ExcludedResources, "volumereplications.replication.storage.openshift.io",
381395
"replicationsources.volsync.backube", "replicationdestinations.volsync.backube",
382396
"PersistentVolumeClaims", "PersistentVolumes"),
383-
LabelSelector: objectsSpec.LabelSelector,
397+
LabelSelector: newLabelSelector,
384398
OrLabelSelectors: objectsSpec.OrLabelSelectors,
385399
TTL: metav1.Duration{}, // TODO: set default here
386400
IncludeClusterResources: objectsSpec.IncludeClusterResources,

0 commit comments

Comments
 (0)