Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch already exist create error on CreateOrUpdate #168

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions controllers/pvc.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"

k8serrors "k8s.io/apimachinery/pkg/api/errors"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -65,7 +66,7 @@ func (r *VolumeSnapshotBackupReconciler) MirrorPVC(log logr.Logger) (bool, error

return r.buildPVCClone(pvcClone, &vsClone)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
r.Log.Info(fmt.Sprintf("err building pvc clone: %v", err))
return false, err
}
Expand Down Expand Up @@ -170,7 +171,7 @@ func (r *VolumeSnapshotBackupReconciler) BindPVCToDummyPod(log logr.Logger) (boo
return err
})

if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
return false, err
}
if op == controllerutil.OperationResultCreated || op == controllerutil.OperationResultUpdated {
Expand Down
3 changes: 2 additions & 1 deletion controllers/replicationdestination.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ func (r *VolumeSnapshotRestoreReconciler) CreateReplicationDestination(log logr.

return r.buildReplicationDestination(repDestination, &vsr, &resticSecret)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
// don't error out if create errors due to replicationDestination already exists
return false, err
}

Expand Down
3 changes: 2 additions & 1 deletion controllers/replicationsource.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func (r *VolumeSnapshotBackupReconciler) CreateReplicationSource(log logr.Logger

return r.buildReplicationSource(repSource, &vsb, &clonedPVC)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
// don't error out if create errors due to replicationSource already exists
return false, err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (r *VolumeSnapshotBackupReconciler) CreateVSBResticSecret(log logr.Logger)

return BuildResticSecret(&resticSecret, rsecret, resticrepo)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
return false, err
}

Expand Down Expand Up @@ -148,7 +148,7 @@ func (r *VolumeSnapshotRestoreReconciler) CreateVSRResticSecret(log logr.Logger)

return BuildResticSecret(&resticSecret, newResticSecret, resticrepo)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
return false, err
}

Expand Down
4 changes: 2 additions & 2 deletions controllers/volumesnapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func (r *VolumeSnapshotBackupReconciler) MirrorVolumeSnapshotContent(log logr.Lo
return r.buildVolumeSnapshotContentClone(vscClone, &vsb)
})

if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
return false, err
}

Expand Down Expand Up @@ -114,7 +114,7 @@ func (r *VolumeSnapshotBackupReconciler) MirrorVolumeSnapshot(log logr.Logger) (

return r.buildVolumeSnapshotClone(vsClone, &vscClone)
})
if err != nil {
if err != nil && !k8serrors.IsAlreadyExists(err){
return false, err
}
if op == controllerutil.OperationResultCreated || op == controllerutil.OperationResultUpdated {
Expand Down