From 347ced07bc430fc187ab7e89754639829c2aed3b Mon Sep 17 00:00:00 2001 From: Benamar Mekhissi Date: Thu, 3 Aug 2023 13:20:47 -0400 Subject: [PATCH] Set PeerReady condition status to false upon relocation initiation Previously, the PeerReady condition status was set to false after the relocation setup between the source and target clusters was completed and before entering the clean up phase. This led to a misleading indication that the peer was ready for a new action before getting to that point. Consequently, users can initiate another action, assuming that the PeerReady condition being true meant it was ready for the next step. To rectify this issue, this commit ensures that as soon as the relocation action is initiated, the PeerReady condition status is immediately switched to false. This change accurately reflects the actual readiness of the peer, preventing any misconceptions about initiating additional actions prematurely. Signed-off-by: Benamar Mekhissi (cherry picked from commit 521f7b6c2c728b203ea8e97e3bc30d7b841c84df) --- controllers/drplacementcontrol.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/controllers/drplacementcontrol.go b/controllers/drplacementcontrol.go index 1d301389e..b3fc1e754 100644 --- a/controllers/drplacementcontrol.go +++ b/controllers/drplacementcontrol.go @@ -741,7 +741,7 @@ func (d *DRPCInstance) RunRelocate() (bool, error) { return !done, fmt.Errorf(errMsg) } - if !d.validatePeerReady() { + if d.getLastDRState() != rmn.Relocating && !d.validatePeerReady() { return !done, fmt.Errorf("clean up on secondaries pending (%+v)", d.instance) } @@ -1044,10 +1044,12 @@ func (d *DRPCInstance) isVRGConditionMet(cluster string, conditionType string) b func (d *DRPCInstance) relocate(preferredCluster, preferredClusterNamespace string, drState rmn.DRState) (bool, error) { const done = true - // Make sure we record the state that we are failing over d.setDRState(drState) addOrUpdateCondition(&d.instance.Status.Conditions, rmn.ConditionAvailable, d.instance.Generation, d.getConditionStatusForTypeAvailable(), string(d.instance.Status.Phase), "Starting relocation") + addOrUpdateCondition(&d.instance.Status.Conditions, rmn.ConditionPeerReady, d.instance.Generation, + metav1.ConditionFalse, rmn.ReasonNotStarted, + fmt.Sprintf("Relocation in progress to cluster %q", preferredCluster)) // Setting up relocation ensures that all VRGs in all managed cluster are secondaries err := d.setupRelocation(preferredCluster) @@ -1069,9 +1071,6 @@ func (d *DRPCInstance) relocate(preferredCluster, preferredClusterNamespace stri d.setDRState(rmn.Relocated) addOrUpdateCondition(&d.instance.Status.Conditions, rmn.ConditionAvailable, d.instance.Generation, d.getConditionStatusForTypeAvailable(), string(d.instance.Status.Phase), "Completed") - addOrUpdateCondition(&d.instance.Status.Conditions, rmn.ConditionPeerReady, d.instance.Generation, - metav1.ConditionFalse, rmn.ReasonNotStarted, - fmt.Sprintf("Started relocation to cluster %q", preferredCluster)) d.log.Info("Relocation completed", "State", d.getLastDRState())