Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
replication: reduce RPC calls when VR state is primary
Browse files Browse the repository at this point in the history
Avoid extra RPC calls as request will be requested again for
updating the LastSyncTime in the status. The image need to be
promoted only one time not always during the reconcile.

fixes: csi-addons#250

Co-authored-by: Madhu Rajanna <[email protected]>
Signed-off-by: yati1998 <[email protected]>
yati1998 and Madhu-1 committed Dec 15, 2022
1 parent e15020b commit c25f536
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion controllers/replication.storage/volumereplication_controller.go
Original file line number Diff line number Diff line change
@@ -273,7 +273,24 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re

switch instance.Spec.ReplicationState {
case replicationv1alpha1.Primary:
replicationErr = r.markVolumeAsPrimary(vr)
// Avoid extra RPC calls as request will be requested again for
// updating the LastSyncTime in the status. The image need to be
// promoted only one time not always during the reconcile.
if instance.Status.State != replicationv1alpha1.PrimaryState {
// enable replication only if its not primary
if err = r.enableReplication(vr); err != nil {
logger.Error(err, "failed to enable replication")
setFailureCondition(instance)
msg := replication.GetMessageFromError(err)
uErr := r.updateReplicationStatus(instance, logger, getCurrentReplicationState(instance), msg)
if uErr != nil {
logger.Error(uErr, "failed to update volumeReplication status", "VRName", instance.Name)
}

return reconcile.Result{}, err
}
replicationErr = r.markVolumeAsPrimary(vr)
}

case replicationv1alpha1.Secondary:
// For the first time, mark the volume as secondary and requeue the

0 comments on commit c25f536

Please sign in to comment.