Skip to content

Commit

Permalink
Check for PVC label selector conflicts against the secondary cluster.
Browse files Browse the repository at this point in the history
Signed-off-by: Gowtham Shanmugasundaram <gshanmug@redhat.com>
  • Loading branch information
GowthamShanmugam committed Feb 20, 2025
1 parent 2753759 commit d8f3da4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/controller/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ func (v *VRGInstance) reconcileVolRepsAsSecondary() bool {
v.pvcStatusDeleteIfPresent(pvc.Namespace, pvc.Name, log)
}

// Ensure that no PVC on the secondary cluster matches the label selector.
// This runs after all protected PVCs have been safely cleaned up in the previous step.
if !requeue && len(v.volRepPVCs) > 0 {
v.log.Info("No PVC on the secondary should match the label selector")
requeue = true
}

if !requeue {
v.log.Info("Successfully reconciled VolRep as Secondary")
}

return requeue
}

Expand Down
9 changes: 9 additions & 0 deletions internal/controller/vrg_volsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,15 @@ func (v *VRGInstance) reconcileVolSyncAsSecondary() bool {

v.instance.Status.ProtectedPVCs = v.instance.Status.ProtectedPVCs[:idx]
v.log.Info("Protected PVCs left", "ProtectedPVCs", v.instance.Status.ProtectedPVCs)
} else {
for _, rdSpec := range v.instance.Spec.VolSync.RDSpec {
for _, pvc := range v.volSyncPVCs {
if pvc.GetName() != rdSpec.ProtectedPVC.Name {
v.log.Info("A PVC that is not a replication destination should not match the label selector.")
return true
}
}
}
}

// Reset status finalsync flags and condition
Expand Down

0 comments on commit d8f3da4

Please sign in to comment.