@@ -133,6 +133,8 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
133133 pvErr error
134134 )
135135
136+ replicationHandle := instance .Spec .ReplicationHandle
137+
136138 nameSpacedName := types.NamespacedName {Name : instance .Spec .DataSource .Name , Namespace : req .Namespace }
137139 switch instance .Spec .DataSource .Kind {
138140 case pvcDataSource :
@@ -154,6 +156,9 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
154156 }
155157
156158 logger .Info ("volume handle" , "VolumeHandleName" , volumeHandle )
159+ if replicationHandle != "" {
160+ logger .Info ("Replication handle" , "ReplicationHandleName" , replicationHandle )
161+ }
157162
158163 // check if the object is being deleted
159164 if instance .GetDeletionTimestamp ().IsZero () {
@@ -167,7 +172,7 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
167172 }
168173 } else {
169174 if contains (instance .GetFinalizers (), volumeReplicationFinalizer ) {
170- err := r .disableVolumeReplication (logger , volumeHandle , parameters , secret )
175+ err := r .disableVolumeReplication (logger , volumeHandle , replicationHandle , parameters , secret )
171176 if err != nil {
172177 logger .Error (err , "failed to disable replication" )
173178 return ctrl.Result {}, err
@@ -195,7 +200,7 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
195200 }
196201
197202 // enable replication on every reconcile
198- if err = r .enableReplication (logger , volumeHandle , parameters , secret ); err != nil {
203+ if err = r .enableReplication (logger , volumeHandle , replicationHandle , parameters , secret ); err != nil {
199204 logger .Error (err , "failed to enable replication" )
200205 setFailureCondition (instance )
201206 _ = r .updateReplicationStatus (instance , logger , getCurrentReplicationState (instance ), err .Error ())
@@ -207,14 +212,14 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
207212
208213 switch instance .Spec .ReplicationState {
209214 case replicationv1alpha1 .Primary :
210- replicationErr = r .markVolumeAsPrimary (instance , logger , volumeHandle , parameters , secret )
215+ replicationErr = r .markVolumeAsPrimary (instance , logger , volumeHandle , replicationHandle , parameters , secret )
211216
212217 case replicationv1alpha1 .Secondary :
213218 // For the first time, mark the volume as secondary and requeue the
214219 // request. For some storage providers it takes some time to determine
215220 // whether the volume need correction example:- correcting split brain.
216221 if instance .Status .State != replicationv1alpha1 .SecondaryState {
217- replicationErr = r .markVolumeAsSecondary (instance , logger , volumeHandle , parameters , secret )
222+ replicationErr = r .markVolumeAsSecondary (instance , logger , volumeHandle , replicationHandle , parameters , secret )
218223 if replicationErr == nil {
219224 logger .Info ("volume is not ready to use" )
220225 // set the status.State to secondary as the
@@ -230,15 +235,15 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
230235 }, nil
231236 }
232237 } else {
233- replicationErr = r .markVolumeAsSecondary (instance , logger , volumeHandle , parameters , secret )
238+ replicationErr = r .markVolumeAsSecondary (instance , logger , volumeHandle , replicationHandle , parameters , secret )
234239 // resync volume if successfully marked Secondary
235240 if replicationErr == nil {
236- requeueForResync , replicationErr = r .resyncVolume (instance , logger , volumeHandle , parameters , secret )
241+ requeueForResync , replicationErr = r .resyncVolume (instance , logger , volumeHandle , replicationHandle , parameters , secret )
237242 }
238243 }
239244
240245 case replicationv1alpha1 .Resync :
241- requeueForResync , replicationErr = r .resyncVolume (instance , logger , volumeHandle , parameters , secret )
246+ requeueForResync , replicationErr = r .resyncVolume (instance , logger , volumeHandle , replicationHandle , parameters , secret )
242247
243248 default :
244249 replicationErr = fmt .Errorf ("unsupported volume state" )
@@ -360,12 +365,15 @@ func (r *VolumeReplicationReconciler) waitForVolumeReplicationResource(logger lo
360365}
361366
362367// markVolumeAsPrimary defines and runs a set of tasks required to mark a volume as primary
363- func (r * VolumeReplicationReconciler ) markVolumeAsPrimary (volumeReplicationObject * replicationv1alpha1.VolumeReplication , logger logr.Logger , volumeID string , parameters , secrets map [string ]string ) error {
368+ func (r * VolumeReplicationReconciler ) markVolumeAsPrimary (volumeReplicationObject * replicationv1alpha1.VolumeReplication ,
369+ logger logr.Logger , volumeID , replicationID string , parameters , secrets map [string ]string ) error {
370+
364371 c := replication.CommonRequestParameters {
365- VolumeID : volumeID ,
366- Parameters : parameters ,
367- Secrets : secrets ,
368- Replication : r .Replication ,
372+ VolumeID : volumeID ,
373+ ReplicationID : replicationID ,
374+ Parameters : parameters ,
375+ Secrets : secrets ,
376+ Replication : r .Replication ,
369377 }
370378
371379 volumeReplication := replication.Replication {
@@ -401,12 +409,14 @@ func (r *VolumeReplicationReconciler) markVolumeAsPrimary(volumeReplicationObjec
401409
402410// markVolumeAsSecondary defines and runs a set of tasks required to mark a volume as secondary
403411func (r * VolumeReplicationReconciler ) markVolumeAsSecondary (volumeReplicationObject * replicationv1alpha1.VolumeReplication ,
404- logger logr.Logger , volumeID string , parameters , secrets map [string ]string ) error {
412+ logger logr.Logger , volumeID , replicationID string , parameters , secrets map [string ]string ) error {
413+
405414 c := replication.CommonRequestParameters {
406- VolumeID : volumeID ,
407- Parameters : parameters ,
408- Secrets : secrets ,
409- Replication : r .Replication ,
415+ VolumeID : volumeID ,
416+ ReplicationID : replicationID ,
417+ Parameters : parameters ,
418+ Secrets : secrets ,
419+ Replication : r .Replication ,
410420 }
411421
412422 volumeReplication := replication.Replication {
@@ -427,12 +437,14 @@ func (r *VolumeReplicationReconciler) markVolumeAsSecondary(volumeReplicationObj
427437
428438// resyncVolume defines and runs a set of tasks required to resync the volume
429439func (r * VolumeReplicationReconciler ) resyncVolume (volumeReplicationObject * replicationv1alpha1.VolumeReplication ,
430- logger logr.Logger , volumeID string , parameters , secrets map [string ]string ) (bool , error ) {
440+ logger logr.Logger , volumeID , replicationID string , parameters , secrets map [string ]string ) (bool , error ) {
441+
431442 c := replication.CommonRequestParameters {
432- VolumeID : volumeID ,
433- Parameters : parameters ,
434- Secrets : secrets ,
435- Replication : r .Replication ,
443+ VolumeID : volumeID ,
444+ ReplicationID : replicationID ,
445+ Parameters : parameters ,
446+ Secrets : secrets ,
447+ Replication : r .Replication ,
436448 }
437449
438450 volumeReplication := replication.Replication {
@@ -467,12 +479,15 @@ func (r *VolumeReplicationReconciler) resyncVolume(volumeReplicationObject *repl
467479}
468480
469481// disableVolumeReplication defines and runs a set of tasks required to disable volume replication
470- func (r * VolumeReplicationReconciler ) disableVolumeReplication (logger logr.Logger , volumeID string , parameters , secrets map [string ]string ) error {
482+ func (r * VolumeReplicationReconciler ) disableVolumeReplication (logger logr.Logger , volumeID , replicationID string ,
483+ parameters , secrets map [string ]string ) error {
484+
471485 c := replication.CommonRequestParameters {
472- VolumeID : volumeID ,
473- Parameters : parameters ,
474- Secrets : secrets ,
475- Replication : r .Replication ,
486+ VolumeID : volumeID ,
487+ ReplicationID : replicationID ,
488+ Parameters : parameters ,
489+ Secrets : secrets ,
490+ Replication : r .Replication ,
476491 }
477492
478493 volumeReplication := replication.Replication {
@@ -494,12 +509,15 @@ func (r *VolumeReplicationReconciler) disableVolumeReplication(logger logr.Logge
494509}
495510
496511// enableReplication enable volume replication on the first reconcile
497- func (r * VolumeReplicationReconciler ) enableReplication (logger logr.Logger , volumeID string , parameters , secrets map [string ]string ) error {
512+ func (r * VolumeReplicationReconciler ) enableReplication (logger logr.Logger , volumeID , replicationID string ,
513+ parameters , secrets map [string ]string ) error {
514+
498515 c := replication.CommonRequestParameters {
499- VolumeID : volumeID ,
500- Parameters : parameters ,
501- Secrets : secrets ,
502- Replication : r .Replication ,
516+ VolumeID : volumeID ,
517+ ReplicationID : replicationID ,
518+ Parameters : parameters ,
519+ Secrets : secrets ,
520+ Replication : r .Replication ,
503521 }
504522
505523 volumeReplication := replication.Replication {
0 commit comments