Skip to content

Commit

Permalink
Update VR condition checks to accomodate Degraded
Browse files Browse the repository at this point in the history
Degraded VR condition was unused, due to condition update
changes from VolumeReplication resource. This has been
corrected by the VolumeReplication code, and hence
VRG processing VR as Secondary needs to adapt to the
Degraded condition as well.

A volume marked Secondary would be:
- Resyncing: true, Degraded: true
OR,
- Resyncing: false, Degraded: false

to denote, a resync in progress or a resync complete.

Added checks to alternate set of conditions [false,false]
to ensure VR transitioned to Secondary as required.

Signed-off-by: Shyamsundar Ranganathan <[email protected]>
  • Loading branch information
ShyamsundarR committed Sep 21, 2021
1 parent 1bbacc9 commit cea2012
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions controllers/volumereplicationgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -1913,8 +1913,8 @@ func (v *VRGInstance) checkVRStatus(volRep *volrep.VolumeReplication) (bool, err
// checked and ensured healthy.
func (v *VRGInstance) validateVRStatus(volRep *volrep.VolumeReplication, state ramendrv1alpha1.ReplicationState) bool {
var (
stateString = "unknown"
action = "unknown"
stateString string
action string
)

const available = true
Expand Down Expand Up @@ -1945,27 +1945,38 @@ func (v *VRGInstance) validateVRStatus(volRep *volrep.VolumeReplication, state r
return available
}

// it should be resyncing, if secondary
conditionMet, msg = isVRConditionMet(volRep, volrepController.ConditionResyncing, metav1.ConditionTrue)
if !conditionMet {
v.updatePVCDataReadyConditionHelper(volRep.Name, VRGConditionReasonError, msg,
"VolumeReplication resource for pvc not resyncing as Secondary")
return v.validateAdditionalVRStatusForSecondary(volRep)
}

return !available
}
func (v *VRGInstance) validateAdditionalVRStatusForSecondary(volRep *volrep.VolumeReplication) bool {
const available = true

// it should not be degraded, if secondary
/* TODO: This needs a fix for https://github.com/csi-addons/volume-replication-operator/issues/101 based on which
this can be removed or uncommented.
conditionMet, msg = isVRConditionMet(volRep, volrepController.ConditionDegraded, metav1.ConditionFalse)
// it should be syncing or not degraded, if secondary
conditionMet, _ := isVRConditionMet(volRep, volrepController.ConditionResyncing, metav1.ConditionTrue)
if !conditionMet {
v.updateProtectedPVCConditionHelper(volRep.Name, VRGConditionReasonError, msg,
"VolumeReplication resource for pvc is degraded")
conditionMet, msg := isVRConditionMet(volRep, volrepController.ConditionResyncing, metav1.ConditionFalse)
if !conditionMet {
v.updatePVCDataReadyConditionHelper(volRep.Name, VRGConditionReasonError, msg,
"VolumeReplication resource for pvc not syncing as Secondary")

return
}*/
return !available
}

conditionMet, msg = isVRConditionMet(volRep, volrepController.ConditionDegraded, metav1.ConditionFalse)
if !conditionMet {
v.updatePVCDataReadyConditionHelper(volRep.Name, VRGConditionReasonError, msg,
"VolumeReplication resource for pvc is not syncing and is degraded as Secondary")

return !available
}

msg = "VolumeReplication resource for the pvc is in sync as Secondary"
v.updatePVCDataReadyCondition(volRep.Name, VRGConditionReasonReplicating, msg)

return available
}

msg = "VolumeReplication resource for the pvc is replicating"
msg := "VolumeReplication resource for the pvc is syncing as Secondary"
v.updatePVCDataReadyCondition(volRep.Name, VRGConditionReasonReplicating, msg)

return available
Expand Down

0 comments on commit cea2012

Please sign in to comment.