Skip to content

Commit

Permalink
Set env vars for datamover batching (#895)
Browse files Browse the repository at this point in the history
  • Loading branch information
eemcmullan committed Feb 1, 2023
1 parent c2f9912 commit 0264a37
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
4 changes: 2 additions & 2 deletions api/v1alpha1/oadp_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ type DataMover struct {
Timeout string `json:"timeout,omitempty"`
// the number of batched volumeSnapshotBackups that can be inProgress at once, default value is 10
// +optional
MaxConcurrentBackupVolumes *int64 `json:"maxConcurrentBackupVolumes,omitempty"`
MaxConcurrentBackupVolumes string `json:"maxConcurrentBackupVolumes,omitempty"`
// the number of batched volumeSnapshotRestores that can be inProgress at once, default value is 10
// +optional
MaxConcurrentRestoreVolumes *int64 `json:"maxConcurrentRestoreVolumes,omitempty"`
MaxConcurrentRestoreVolumes string `json:"maxConcurrentRestoreVolumes,omitempty"`
}

// Features defines the configuration for the DPA to enable the tech preview features
Expand Down
12 changes: 1 addition & 11 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,10 @@ spec:
type: boolean
maxConcurrentBackupVolumes:
description: the number of batched volumeSnapshotBackups that can be inProgress at once, default value is 10
format: int64
type: integer
type: string
maxConcurrentRestoreVolumes:
description: the number of batched volumeSnapshotRestores that can be inProgress at once, default value is 10
format: int64
type: integer
type: string
timeout:
description: User supplied timeout to be used for VolumeSnapshotBackup and VolumeSnapshotRestore to complete, default value is 10m
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,10 @@ spec:
type: boolean
maxConcurrentBackupVolumes:
description: the number of batched volumeSnapshotBackups that can be inProgress at once, default value is 10
format: int64
type: integer
type: string
maxConcurrentRestoreVolumes:
description: the number of batched volumeSnapshotRestores that can be inProgress at once, default value is 10
format: int64
type: integer
type: string
timeout:
description: User supplied timeout to be used for VolumeSnapshotBackup and VolumeSnapshotRestore to complete, default value is 10m
type: string
Expand Down
53 changes: 52 additions & 1 deletion controllers/datamover.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ const (
ResticRepository = "RESTIC_REPOSITORY"
ResticsecretName = "dm-credential"

// batchNumbers vars
DefaultConcurrentBackupVolumes = "10"
DefaultConcurrentRestoreVolumes = "10"
DataMoverConcurrentBackup = "DATAMOVER_CONCURRENT_BACKUP"
DataMoverConcurrentRestore = "DATAMOVER_CONCURRENT_RESTORE"

// AWS vars
AWSAccessKey = "AWS_ACCESS_KEY_ID"
AWSSecretKey = "AWS_SECRET_ACCESS_KEY"
Expand Down Expand Up @@ -105,7 +111,7 @@ func (r *DPAReconciler) ReconcileDataMoverController(log logr.Logger) (bool, err
return true, nil
}

op, err := controllerutil.CreateOrPatch(r.Context, r.Client, dataMoverDeployment, func() error {
op, err := controllerutil.CreateOrUpdate(r.Context, r.Client, dataMoverDeployment, func() error {

// Setting Deployment selector if a new object is created as it is immutable
if dataMoverDeployment.ObjectMeta.CreationTimestamp.IsZero() {
Expand Down Expand Up @@ -195,6 +201,51 @@ func (r *DPAReconciler) buildDataMoverDeployment(dataMoverDeployment *appsv1.Dep
},
}

var dataMoverContainer *corev1.Container
for i, container := range datamoverContainer {
if container.Name == common.DataMoverControllerContainer {
dataMoverContainer = &datamoverContainer[i]
break
}
}

if err := r.customizeDataMoverContainer(dpa, dataMoverContainer); err != nil {
return err
}

return nil
}

func (r *DPAReconciler) customizeDataMoverContainer(dpa *oadpv1alpha1.DataProtectionApplication, dataMoverContainer *corev1.Container) error {

if dataMoverContainer == nil {
return fmt.Errorf("could not find dataMover container in Deployment")
}

if len(dpa.Spec.Features.DataMover.MaxConcurrentBackupVolumes) > 0 {
dataMoverContainer.Env = append(dataMoverContainer.Env, corev1.EnvVar{
Name: DataMoverConcurrentBackup,
Value: dpa.Spec.Features.DataMover.MaxConcurrentBackupVolumes,
})
} else {
dataMoverContainer.Env = append(dataMoverContainer.Env, corev1.EnvVar{
Name: DataMoverConcurrentBackup,
Value: DefaultConcurrentBackupVolumes,
})
}

if len(dpa.Spec.Features.DataMover.MaxConcurrentRestoreVolumes) > 0 {
dataMoverContainer.Env = append(dataMoverContainer.Env, corev1.EnvVar{
Name: DataMoverConcurrentRestore,
Value: dpa.Spec.Features.DataMover.MaxConcurrentRestoreVolumes,
})
} else {
dataMoverContainer.Env = append(dataMoverContainer.Env, corev1.EnvVar{
Name: DataMoverConcurrentRestore,
Value: DefaultConcurrentRestoreVolumes,
})
}

return nil
}

Expand Down
10 changes: 10 additions & 0 deletions controllers/datamover_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ func TestDPAReconciler_buildDataMoverDeployment(t *testing.T) {
Image: common.DataMoverImage,
Name: common.DataMoverControllerContainer,
ImagePullPolicy: corev1.PullAlways,
Env: []corev1.EnvVar{
{
Name: DataMoverConcurrentBackup,
Value: DefaultConcurrentBackupVolumes,
},
{
Name: DataMoverConcurrentRestore,
Value: DefaultConcurrentRestoreVolumes,
},
},
},
},
ServiceAccountName: "openshift-adp-controller-manager",
Expand Down

0 comments on commit 0264a37

Please sign in to comment.