Skip to content

Commit

Permalink
OADP-849: fix replicationDestination race condition (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-pampattiwar authored Nov 1, 2022
1 parent 2204004 commit 9378a92
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion controllers/replicationdestination.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/go-logr/logr"
volsnapmoverv1alpha1 "github.com/konveyor/volume-snapshot-mover/api/v1alpha1"
corev1 "k8s.io/api/core/v1"
k8serror "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -116,16 +117,24 @@ func (r *VolumeSnapshotRestoreReconciler) SetVSRStatus(log logr.Logger) (bool, e
}

if vsr.Status.Phase == volsnapmoverv1alpha1.SnapMoverRestorePhaseFailed || vsr.Status.Phase == volsnapmoverv1alpha1.SnapMoverRestorePhasePartiallyFailed {
return false, errors.New("vsb failed to complete")
return false, errors.New(fmt.Sprintf("vsr %s/%s failed to complete", vsr.Namespace, vsr.Name))
}

repDestName := fmt.Sprintf("%s-rep-dest", vsr.Name)
repDest := volsyncv1alpha1.ReplicationDestination{}
if err := r.Get(r.Context, types.NamespacedName{Namespace: vsr.Spec.ProtectedNamespace, Name: repDestName}, &repDest); err != nil {
if k8serror.IsNotFound(err) {
return false, nil
}
r.Log.Info(fmt.Sprintf("error getting replicationdestination %s/%s", vsr.Spec.ProtectedNamespace, repDestName))
return false, err
}

if repDest.Status == nil {
r.Log.Info(fmt.Sprintf("replication destination %s/%s is yet to have a status", vsr.Spec.ProtectedNamespace, repDest))
return false, nil
}

if repDest.Status != nil {
reconConditionProgress := metav1.Condition{}

Expand Down

0 comments on commit 9378a92

Please sign in to comment.