@@ -173,7 +173,7 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
173
173
vgr , vgrc , vgrErr = r .getVolumeGroupReplicationDataSource (logger , nameSpacedName )
174
174
if vgrErr != nil {
175
175
if errors .IsNotFound (vgrErr ) && ! instance .DeletionTimestamp .IsZero () {
176
- logger .Info ("volumeGroupReplication resource not found, as volumeReplication resource is getting garbage collected" )
176
+ logger .Info ("volumeGroupReplicationContent resource not found, as volumeReplication resource is getting garbage collected" )
177
177
break
178
178
}
179
179
logger .Error (vgrErr , "failed to get VolumeGroupReplication" , "VGRName" , instance .Spec .DataSource .Name )
@@ -278,9 +278,14 @@ func (r *VolumeReplicationReconciler) Reconcile(ctx context.Context, req ctrl.Re
278
278
return reconcile.Result {}, err
279
279
}
280
280
case volumeGroupReplicationDataSource :
281
- if err = removeFinalizerFromVGRContent (r .Client , logger , vgrc , volumeReplicationFinalizer ); err != nil {
282
- logger .Error (err , "Failed to remove VolumeReplication finalizer from VolumeGroupReplicationContent resource" )
283
- return reconcile.Result {}, err
281
+ // It is possible that the VGRContent has already been deleted
282
+ // as the finalizer was removed in a previous reconcile loop,
283
+ // and this is a reconcile that happened after that deletion.
284
+ if vgrc != nil {
285
+ if err = removeFinalizerFromVGRContent (r .Client , logger , vgrc , volumeReplicationFinalizer ); err != nil {
286
+ logger .Error (err , "Failed to remove VolumeReplication finalizer from VolumeGroupReplicationContent resource" )
287
+ return reconcile.Result {}, err
288
+ }
284
289
}
285
290
286
291
err = r .removeOwnerFromVGRAnnotation (ctx , logger , vgr )
@@ -822,7 +827,7 @@ func (r *VolumeReplicationReconciler) getVolumeGroupReplicationDataSource(logger
822
827
if vgrcName == "" {
823
828
logger .Error (err , "VolumeGroupReplicationContentName is empty" , "VolumeGroupReplication Name" , req .Name )
824
829
825
- return nil , nil , stderrors .New ("VolumeGroupReplicationContentName is empty" )
830
+ return volumeGroupReplication , nil , stderrors .New ("VolumeGroupReplicationContentName is empty" )
826
831
}
827
832
828
833
vgrcReq := types.NamespacedName {Name : vgrcName }
@@ -833,7 +838,7 @@ func (r *VolumeReplicationReconciler) getVolumeGroupReplicationDataSource(logger
833
838
logger .Error (err , "VolumeGroupReplicationContent not found" , "VolumeGroupReplicationContent Name" , vgrcName )
834
839
}
835
840
836
- return nil , nil , err
841
+ return volumeGroupReplication , nil , err
837
842
}
838
843
839
844
return volumeGroupReplication , volumeGroupReplicationContent , nil
0 commit comments