Skip to content
This repository was archived by the owner on Dec 12, 2024. It is now read-only.

Commit fc53e3c

Browse files
committed
ctrl: EnableReplication only for primary state
call EnableVolumeReplication only if the request is to mark the image as primary Signed-off-by: Madhu Rajanna <[email protected]>
1 parent 4fff664 commit fc53e3c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

controllers/volumereplication_controller.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)