@@ -199,19 +199,21 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
199199 return reconcile.Result {}, err
200200 }
201201
202- // enable replication on every reconcile
203- if err = r .enableReplication (logger , volumeHandle , replicationHandle , parameters , secret ); err != nil {
204- logger .Error (err , "failed to enable replication" )
205- setFailureCondition (instance )
206- _ = r .updateReplicationStatus (instance , logger , getCurrentReplicationState (instance ), err .Error ())
207- return reconcile.Result {}, err
208- }
209-
210202 var replicationErr error
211203 var requeueForResync bool
212204
213205 switch instance .Spec .ReplicationState {
214206 case replicationv1alpha1 .Primary :
207+ // Send EnableVolumeReplication request only if the request is new or a
208+ // failed requeue request.
209+ if instance .Status .State == "" || instance .Status .State == replicationv1alpha1 .UnknownState {
210+ if err = r .enableReplication (logger , volumeHandle , replicationHandle , parameters , secret ); err != nil {
211+ logger .Error (err , "failed to enable replication" )
212+ setFailureCondition (instance )
213+ _ = r .updateReplicationStatus (instance , logger , getCurrentReplicationState (instance ), err .Error ())
214+ return reconcile.Result {}, err
215+ }
216+ }
215217 replicationErr = r .markVolumeAsPrimary (instance , logger , volumeHandle , replicationHandle , parameters , secret )
216218
217219 case replicationv1alpha1 .Secondary :
0 commit comments