Skip to content

Commit

Permalink
Update unused messages for Volrep and remove PVCs from status once se…
Browse files Browse the repository at this point in the history
…condary

Signed-off-by: Shyamsundar Ranganathan <[email protected]>
  • Loading branch information
ShyamsundarR authored and BenamarMk committed Nov 16, 2024
1 parent 39c619a commit e4180c5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 13 deletions.
15 changes: 8 additions & 7 deletions internal/controller/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1541,15 +1541,13 @@ func (v *VRGInstance) updateVRGConditions() {
func (v *VRGInstance) vrgReadyStatus(reason string) *metav1.Condition {
v.log.Info("Marking VRG ready with replicating reason", "reason", reason)

unusedMsg := "No PVCs are protected using VolumeReplication scheme"
if v.instance.Spec.Sync != nil {
unusedMsg = "No PVCs are protected, no PVCs found matching the selector"
}

if v.instance.Spec.ReplicationState == ramendrv1alpha1.Secondary {
msg := "PVCs in the VolumeReplicationGroup group are replicating"
if reason == VRGConditionReasonUnused {
msg = unusedMsg
msg = "PVC protection as secondary is complete, or no PVCs needed protection using VolumeReplication scheme"
if v.instance.Spec.Sync != nil {
msg = "PVC protection as secondary is complete, or no PVCs needed protection"
}
} else {
reason = VRGConditionReasonReplicating
}
Expand All @@ -1560,7 +1558,10 @@ func (v *VRGInstance) vrgReadyStatus(reason string) *metav1.Condition {
// VRG as primary
msg := "PVCs in the VolumeReplicationGroup are ready for use"
if reason == VRGConditionReasonUnused {
msg = unusedMsg
msg = "No PVCs are protected using VolumeReplication scheme"
if v.instance.Spec.Sync != nil {
msg = "No PVCs are protected, no PVCs found matching the selector"
}
}

return newVRGAsPrimaryReadyCondition(v.instance.Generation, reason, msg)
Expand Down
33 changes: 27 additions & 6 deletions internal/controller/vrg_volrep.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,18 +114,20 @@ func (v *VRGInstance) reconcileVolRepsAsPrimary() {

// reconcileVolRepsAsSecondary reconciles VolumeReplication resources for the VRG as secondary
//
//nolint:gocognit,cyclop
//nolint:gocognit,cyclop,funlen
func (v *VRGInstance) reconcileVolRepsAsSecondary() bool {
requeue := false

for idx := range v.volRepPVCs {
pvc := &v.volRepPVCs[idx]
log := logWithPvcName(v.log, pvc)

// Potentially for PVCs that are not deleted
// Potentially for PVCs that are not deleted, e.g Failover of STS without required auto delete options
if !containsString(pvc.Finalizers, PvcVRFinalizerProtected) {
log.Info("pvc does not contain VR protection finalizer. Skipping it")

v.pvcStatusDeleteIfPresent(pvc.Namespace, pvc.Name, log)

continue
}

Expand All @@ -148,7 +150,7 @@ func (v *VRGInstance) reconcileVolRepsAsSecondary() bool {

vrMissing, requeueResult := v.reconcileMissingVR(pvc, log)
if vrMissing || requeueResult {
v.requeue()
requeue = true

continue
}
Expand All @@ -166,9 +168,13 @@ func (v *VRGInstance) reconcileVolRepsAsSecondary() bool {
continue
}

// Not removed from protectedPVC list
// cleanupProtectedPVCs
return v.undoPVCFinalizersAndPVRetention(pvc, log)
if v.undoPVCFinalizersAndPVRetention(pvc, log) {
requeue = true

continue
}

v.pvcStatusDeleteIfPresent(pvc.Namespace, pvc.Name, log)
}

return requeue
Expand Down Expand Up @@ -2567,6 +2573,16 @@ func (v *VRGInstance) aggregateVolRepDataReadyCondition() *metav1.Condition {
//nolint:funlen,gocognit,cyclop
func (v *VRGInstance) aggregateVolRepDataProtectedCondition() *metav1.Condition {
if len(v.volRepPVCs) == 0 {
if v.instance.Spec.ReplicationState == ramendrv1alpha1.Secondary {
if v.instance.Spec.Sync != nil {
return newVRGAsDataProtectedUnusedCondition(v.instance.Generation,
"PVC protection as secondary is complete, or no PVCs needed protection")
}

return newVRGAsDataProtectedUnusedCondition(v.instance.Generation,
"PVC protection as secondary is complete, or no PVCs needed protection using VolumeReplication scheme")
}

if v.instance.Spec.Sync != nil {
return newVRGAsDataProtectedUnusedCondition(v.instance.Generation,
"No PVCs are protected, no PVCs found matching the selector")
Expand Down Expand Up @@ -2649,6 +2665,11 @@ func (v *VRGInstance) aggregateVolRepDataProtectedCondition() *metav1.Condition
// protecting condition, set the VRG level condition to protecting. If not, set
// the VRG level condition to true.
func (v *VRGInstance) aggregateVolRepClusterDataProtectedCondition() *metav1.Condition {
if v.instance.Spec.ReplicationState == ramendrv1alpha1.Secondary {
return newVRGClusterDataProtectedUnusedCondition(v.instance.Generation,
"Cluster data is not protected as Secondary")
}

if len(v.volRepPVCs) == 0 {
if v.instance.Spec.Sync != nil {
return newVRGAsDataProtectedUnusedCondition(v.instance.Generation,
Expand Down

0 comments on commit e4180c5

Please sign in to comment.