Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions tests/e2e/lib/dpa_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"reflect"
"strings"
"time"

"github.com/openshift/oadp-operator/pkg/common"

Expand Down Expand Up @@ -139,17 +140,33 @@ func (v *DpaCustomResource) GetNoErr() *oadpv1alpha1.DataProtectionApplication {
}

func (v *DpaCustomResource) CreateOrUpdate(spec *oadpv1alpha1.DataProtectionApplicationSpec) error {
cr, err := v.Get()
if apierrors.IsNotFound(err) {
v.Build(v.backupRestoreType)
v.CustomResource.Spec = *spec
return v.Create()
}
if err != nil {
return err
return v.CreateOrUpdateWithRetries(spec, 3)
}
func (v *DpaCustomResource) CreateOrUpdateWithRetries(spec *oadpv1alpha1.DataProtectionApplicationSpec, retries int) error {
var (
err error
cr *oadpv1alpha1.DataProtectionApplication
)
for i := 0; i < retries; i++ {
if cr, err = v.Get(); apierrors.IsNotFound(err) {
v.Build(v.backupRestoreType)
v.CustomResource.Spec = *spec
return v.Create()
} else if err != nil {
return err
}
cr.Spec = *spec
if err = v.Client.Update(context.Background(), cr); err != nil{
if apierrors.IsConflict(err) && i < retries-1 {
log.Println("conflict detected during DPA CreateOrUpdate, retrying for ", retries - i - 1 , " more times")
time.Sleep(time.Second * 2)
continue
}
return err
}
return nil
}
cr.Spec = *spec
return v.Client.Update(context.Background(), cr)
return err
}

func (v *DpaCustomResource) Delete() error {
Expand Down