diff --git a/api/v1alpha1/dataprotectionapplication_types.go b/api/v1alpha1/dataprotectionapplication_types.go index 209756c5ca..0051f77cb7 100644 --- a/api/v1alpha1/dataprotectionapplication_types.go +++ b/api/v1alpha1/dataprotectionapplication_types.go @@ -373,6 +373,11 @@ type VeleroConfig struct { // LoadAffinityConfig is the config for data path load affinity. // +optional LoadAffinityConfig []*LoadAffinity `json:"loadAffinity,omitempty"` + // set DisableCSISnapshotEarlyFrequentPolling to true to omit + // the 1-second polling interval for the first 10 seconds while waiting + // for the snaphandle + // +optional + DisableCSISnapshotEarlyFrequentPolling bool `json:"disableCSISnapshotEarlyFrequentPolling,omitempty"` } // PodConfig defines the pod configuration options diff --git a/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml b/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml index 37c296c01e..f0e545a949 100644 --- a/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml +++ b/bundle/manifests/oadp.openshift.io_dataprotectionapplications.yaml @@ -1221,6 +1221,12 @@ spec: Use pod volume file system backup by default for volumes. Matches backup.spec.defaultVolumesToFsBackup in Velero API. type: boolean + disableCSISnapshotEarlyFrequentPolling: + description: |- + set DisableCSISnapshotEarlyFrequentPolling to true to omit + the 1-second polling interval for the first 10 seconds while waiting + for the snaphandle + type: boolean disableFsBackup: default: false description: |- diff --git a/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml b/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml index 656801a135..6d4943d506 100644 --- a/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml +++ b/config/crd/bases/oadp.openshift.io_dataprotectionapplications.yaml @@ -1221,6 +1221,12 @@ spec: Use pod volume file system backup by default for volumes. Matches backup.spec.defaultVolumesToFsBackup in Velero API. type: boolean + disableCSISnapshotEarlyFrequentPolling: + description: |- + set DisableCSISnapshotEarlyFrequentPolling to true to omit + the 1-second polling interval for the first 10 seconds while waiting + for the snaphandle + type: boolean disableFsBackup: default: false description: |- diff --git a/internal/controller/velero.go b/internal/controller/velero.go index 99d0005b11..65a4267f36 100644 --- a/internal/controller/velero.go +++ b/internal/controller/velero.go @@ -673,6 +673,12 @@ func (r *DataProtectionApplicationReconciler) customizeVeleroContainer(veleroCon Value: "true", }}) } + if dpa.Spec.Configuration.Velero == nil || !dpa.Spec.Configuration.Velero.DisableCSISnapshotEarlyFrequentPolling { + veleroContainer.Env = common.AppendUniqueEnvVars(veleroContainer.Env, []corev1.EnvVar{{ + Name: "CSI_SNAPSHOT_EARLY_FREQUENT_POLLING", + Value: "true", + }}) + } // Add Azure workload identity environment variables if using Azure STS azureClientID := os.Getenv(stsflow.ClientIDEnvKey) diff --git a/internal/controller/velero_test.go b/internal/controller/velero_test.go index c89baedbf1..6a3f2da150 100644 --- a/internal/controller/velero_test.go +++ b/internal/controller/velero_test.go @@ -98,6 +98,7 @@ var ( }, {Name: common.LDLibraryPathEnvKey, Value: "/plugins"}, {Name: "OPENSHIFT_IMAGESTREAM_BACKUP", Value: "true"}, + {Name: "CSI_SNAPSHOT_EARLY_FREQUENT_POLLING", Value: "true"}, } baseVolumeMounts = []corev1.VolumeMount{ @@ -2574,6 +2575,55 @@ func TestDPAReconciler_buildVeleroDeployment(t *testing.T) { }, {Name: common.LDLibraryPathEnvKey, Value: "/plugins"}, // Note: OPENSHIFT_IMAGESTREAM_BACKUP is NOT included when BackupImages is false + {Name: "CSI_SNAPSHOT_EARLY_FREQUENT_POLLING", Value: "true"}, + }, + }), + }, + { + name: "valid DPA CR with DisableCSISnapshotEarlyFrequentPolling true, no CSI_SNAPSHOT_EARLY_FREQUENT_POLLING", + dpa: createTestDpaWith( + nil, + oadpv1alpha1.DataProtectionApplicationSpec{ + Configuration: &oadpv1alpha1.ApplicationConfig{ + Velero: &oadpv1alpha1.VeleroConfig{ + DisableCSISnapshotEarlyFrequentPolling: true, + }, + }, + BackupImages: ptr.To(false), + BackupLocations: []oadpv1alpha1.BackupLocation{ + { + Velero: &velerov1.BackupStorageLocationSpec{ + Provider: "aws", + StorageType: velerov1.StorageType{ + ObjectStorage: &velerov1.ObjectStorageLocation{ + CACert: []byte("test-ca-cert"), + }, + }, + }, + }, + }, + }, + ), + veleroDeployment: testVeleroDeployment.DeepCopy(), + wantVeleroDeployment: createTestBuiltVeleroDeployment(TestBuiltVeleroDeploymentOptions{ + args: []string{ + defaultFileSystemBackupTimeout, + defaultRestoreResourcePriorities, + defaultDisableInformerCache, + }, + // When BackupImages is false, OPENSHIFT_IMAGESTREAM_BACKUP env var is not set + env: []corev1.EnvVar{ + {Name: common.VeleroScratchDirEnvKey, Value: "/scratch"}, + { + Name: common.VeleroNamespaceEnvKey, + ValueFrom: &corev1.EnvVarSource{ + FieldRef: &corev1.ObjectFieldSelector{ + APIVersion: "v1", + FieldPath: "metadata.namespace", + }, + }, + }, + {Name: common.LDLibraryPathEnvKey, Value: "/plugins"}, }, }), },