diff --git a/api/v1alpha1/dataprotectionapplication_types.go b/api/v1alpha1/dataprotectionapplication_types.go index 54414214bcd..3a31c80815d 100644 --- a/api/v1alpha1/dataprotectionapplication_types.go +++ b/api/v1alpha1/dataprotectionapplication_types.go @@ -327,7 +327,11 @@ type VeleroConfig struct { // How long to wait on asynchronous BackupItemActions and RestoreItemActions to complete before timing out. Default value is 1h. // +optional DefaultItemOperationTimeout string `json:"defaultItemOperationTimeout,omitempty"` - // Use pod volume file system backup by default for volumes + // Use pod volume file system backup by default for volumes. + // Matches backup.spec.defaultVolumesToFsBackup in Velero API. + // +optional + DefaultVolumesToFsBackup *bool `json:"defaultVolumesToFsBackup,omitempty"` + // Deprecated: Use defaultVolumesToFsBackup instead (matches Velero backup spec). // +optional DefaultVolumesToFSBackup *bool `json:"defaultVolumesToFSBackup,omitempty"` // DisableFsBackup determines whether the NodeAgent should disable file system backup. diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index ea56fc4066d..5482d5af80f 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -1326,6 +1326,11 @@ func (in *VeleroConfig) DeepCopyInto(out *VeleroConfig) { *out = new(PodConfig) (*in).DeepCopyInto(*out) } + if in.DefaultVolumesToFsBackup != nil { + in, out := &in.DefaultVolumesToFsBackup, &out.DefaultVolumesToFsBackup + *out = new(bool) + **out = **in + } if in.DefaultVolumesToFSBackup != nil { in, out := &in.DefaultVolumesToFSBackup, &out.DefaultVolumesToFSBackup *out = new(bool) diff --git a/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml b/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml index a0e4a4fc269..57a167862f1 100644 --- a/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml +++ b/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml @@ -1181,7 +1181,12 @@ spec: description: Specify whether CSI snapshot data should be moved to backup storage by default type: boolean defaultVolumesToFSBackup: - description: Use pod volume file system backup by default for volumes + description: 'Deprecated: Use defaultVolumesToFsBackup instead (matches Velero backup spec).' + type: boolean + defaultVolumesToFsBackup: + description: |- + Use pod volume file system backup by default for volumes. + Matches backup.spec.defaultVolumesToFsBackup in Velero API. type: boolean disableFsBackup: default: false diff --git a/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml b/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml index a485a62b207..5f58182539a 100644 --- a/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml +++ b/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml @@ -1181,7 +1181,12 @@ spec: description: Specify whether CSI snapshot data should be moved to backup storage by default type: boolean defaultVolumesToFSBackup: - description: Use pod volume file system backup by default for volumes + description: 'Deprecated: Use defaultVolumesToFsBackup instead (matches Velero backup spec).' + type: boolean + defaultVolumesToFsBackup: + description: |- + Use pod volume file system backup by default for volumes. + Matches backup.spec.defaultVolumesToFsBackup in Velero API. type: boolean disableFsBackup: default: false diff --git a/internal/controller/velero.go b/internal/controller/velero.go index 5a4b565d42e..40b16a5eeee 100644 --- a/internal/controller/velero.go +++ b/internal/controller/velero.go @@ -411,7 +411,7 @@ func (r *DataProtectionApplicationReconciler) customizeVeleroDeployment(veleroDe // check for default-snapshot-move-data parameter defaultSnapshotMoveData := getDefaultSnapshotMoveDataValue(dpa) // check for default-volumes-to-fs-backup - defaultVolumesToFSBackup := getDefaultVolumesToFSBackup(dpa) + defaultVolumesToFsBackup := getDefaultVolumesToFsBackup(dpa) // check for default-snapshot-move-data if len(defaultSnapshotMoveData) > 0 { @@ -419,8 +419,8 @@ func (r *DataProtectionApplicationReconciler) customizeVeleroDeployment(veleroDe } // check for default-volumes-to-fs-backup - if len(defaultVolumesToFSBackup) > 0 { - veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--default-volumes-to-fs-backup=%s", defaultVolumesToFSBackup)) + if len(defaultVolumesToFsBackup) > 0 { + veleroContainer.Args = append(veleroContainer.Args, fmt.Sprintf("--default-volumes-to-fs-backup=%s", defaultVolumesToFsBackup)) } // check for disable-informer-cache flag @@ -726,15 +726,22 @@ func getDefaultSnapshotMoveDataValue(dpa *oadpv1alpha1.DataProtectionApplication return "" } -func getDefaultVolumesToFSBackup(dpa *oadpv1alpha1.DataProtectionApplication) string { - if dpa.Spec.Configuration.Velero != nil && boolptr.IsSetToTrue(dpa.Spec.Configuration.Velero.DefaultVolumesToFSBackup) { +func getDefaultVolumesToFsBackup(dpa *oadpv1alpha1.DataProtectionApplication) string { + velero := dpa.Spec.Configuration.Velero + if velero == nil { + return "" + } + // Prefer new field (matches Velero backup.spec.defaultVolumesToFsBackup), fall back to deprecated field + val := velero.DefaultVolumesToFsBackup + if val == nil { + val = velero.DefaultVolumesToFSBackup + } + if boolptr.IsSetToTrue(val) { return TrueVal } - - if dpa.Spec.Configuration.Velero != nil && boolptr.IsSetToFalse(dpa.Spec.Configuration.Velero.DefaultVolumesToFSBackup) { + if boolptr.IsSetToFalse(val) { return FalseVal } - return "" } diff --git a/internal/controller/velero_test.go b/internal/controller/velero_test.go index 057d4f7960c..e985eafe1ce 100644 --- a/internal/controller/velero_test.go +++ b/internal/controller/velero_test.go @@ -1210,7 +1210,7 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) { DefaultItemOperationTimeout: "2h", DefaultSnapshotMoveData: ptr.To(false), NoDefaultBackupLocation: true, - DefaultVolumesToFSBackup: ptr.To(true), + DefaultVolumesToFsBackup: ptr.To(true), DefaultPlugins: []oadpv1alpha1.DefaultPlugin{oadpv1alpha1.DefaultPluginCSI}, }, }, @@ -1278,7 +1278,29 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) { }), }, { - name: "valid DPA CR with DefaultVolumesToFSBackup true, Velero Deployment is built with DefaultVolumesToFSBackup true", + name: "valid DPA CR with DefaultVolumesToFsBackup true (new field), Velero Deployment is built with default-volumes-to-fs-backup true", + dpa: createTestDpaWith( + nil, + oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultVolumesToFsBackup: ptr.To(true), + }, + }, + }, + ), + veleroDeployment: testVeleroDeployment.DeepCopy(), + wantVeleroDeployment: createTestBuiltVeleroDeployment(TestBuiltVeleroDeploymentOptions{ + args: []string{ + defaultFileSystemBackupTimeout, + defaultRestoreResourcePriorities, + "--default-volumes-to-fs-backup=true", + defaultDisableInformerCache, + }, + }), + }, + { + name: "valid DPA CR with DefaultVolumesToFSBackup true (deprecated field, backwards compat), Velero Deployment is built with default-volumes-to-fs-backup true", dpa: createTestDpaWith( nil, oadpv1alpha1.DataProtectionApplicationSpec{ @@ -1299,6 +1321,29 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) { }, }), }, + { + name: "valid DPA CR with both DefaultVolumesToFsBackup and DefaultVolumesToFSBackup set, new field takes precedence", + dpa: createTestDpaWith( + nil, + oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DefaultVolumesToFsBackup: ptr.To(false), + DefaultVolumesToFSBackup: ptr.To(true), // deprecated, should be ignored + }, + }, + }, + ), + veleroDeployment: testVeleroDeployment.DeepCopy(), + wantVeleroDeployment: createTestBuiltVeleroDeployment(TestBuiltVeleroDeploymentOptions{ + args: []string{ + defaultFileSystemBackupTimeout, + defaultRestoreResourcePriorities, + "--default-volumes-to-fs-backup=false", + defaultDisableInformerCache, + }, + }), + }, { name: "valid DPA CR with DisableInformerCache true, Velero Deployment is built with DisableInformerCache true", dpa: createTestDpaWith(