@@ -110,15 +110,15 @@ func (d *DRPCInstance) processPlacement() (bool, error) {
110110 d .log .Info ("Process DRPC Placement" , "DRAction" , d .instance .Spec .Action )
111111
112112 // Handle test failover cleanup when switching away from test failover to another action
113- if d .instance .Spec .Action != rmn . ActionTestFailover {
113+ if ! d .instance .Spec .DryRun {
114114 rmnutil .AddAnnotation (d .instance , "ramendr.openshift.io/last-action" , string (d .instance .Spec .Action ))
115115
116116 // If we're exiting a test failover (were in TestingFailover progression), clean up placement
117117 // decisions that were retained during the test, then requeue for the new action.
118118 if d .instance .Status .Progression == rmn .ProgressionTestingFailover {
119119 for clusterName , vrg := range d .vrgs {
120120 // Find the primary VRG that was used for testing and clean up after it
121- if isVRGPrimary (vrg ) && vrg .Spec .Action == rmn . VRGActionTestFailover {
121+ if isVRGPrimary (vrg ) && vrg .Spec .DryRun {
122122 // Remove cluster decision that was retained during test failover
123123 if err := d .reconciler .removeClusterDecisionAfterTestFailover (d .ctx , d .userPlacement , clusterName ); err != nil {
124124 return false , err
@@ -143,8 +143,6 @@ func (d *DRPCInstance) executeAction() (bool, error) {
143143 return d .RunFailover ()
144144 case rmn .ActionRelocate :
145145 return d .RunRelocate ()
146- case rmn .ActionTestFailover :
147- return d .RunTestFailover ()
148146 }
149147
150148 // Not a failover or a relocation. Must be an initial deployment.
@@ -366,7 +364,7 @@ func (d *DRPCInstance) startDeploying(homeCluster, homeClusterNamespace string)
366364// on the failover cluster
367365// 3. Else, initiate failover to the desired failoverCluster (switchToFailoverCluster)
368366//
369- //nolint:cyclop,funlen,nestif
367+ //nolint:cyclop,funlen,nestif,gocognit
370368func (d * DRPCInstance ) RunFailover () (bool , error ) {
371369 d .log .Info ("Entering RunFailover" , "state" , d .getLastDRState ())
372370
@@ -417,7 +415,7 @@ func (d *DRPCInstance) RunFailover() (bool, error) {
417415 metav1 .ConditionTrue , string (d .instance .Status .Phase ), "Completed" )
418416
419417 // Opltimize by adding a reconciler so that we reconcile at 1 minute at most.
420- if d .instance .Spec .Action == rmn .ActionTestFailover {
418+ if d .instance .Spec .DryRun && d . instance . Spec . Action == rmn .ActionFailover {
421419 d .setProgression (rmn .ProgressionTestingFailover )
422420
423421 if err := d .ensurePlacement (failoverCluster ); err != nil {
@@ -1184,7 +1182,7 @@ func (d *DRPCInstance) areMultipleVRGsPrimary() bool {
11841182 numOfPrimaries := 0
11851183
11861184 for _ , vrg := range d .vrgs {
1187- if isVRGPrimary (vrg ) && vrg .Spec .Action != rmn . VRGActionTestFailover {
1185+ if isVRGPrimary (vrg ) && ! vrg .Spec .DryRun {
11881186 numOfPrimaries ++
11891187 }
11901188 }
@@ -1534,7 +1532,7 @@ func (d *DRPCInstance) updateUserPlacementRule(homeCluster, reason string) error
15341532 d .userPlacement .GetName (), homeCluster ))
15351533
15361534 added := false
1537- if d .instance .Spec .Action != rmn . ActionTestFailover {
1535+ if ! d .instance .Spec .DryRun {
15381536 added = rmnutil .AddAnnotation (d .instance , LastAppDeploymentCluster , homeCluster )
15391537 }
15401538
@@ -1958,8 +1956,6 @@ func vrgAction(drpcAction rmn.DRAction) rmn.VRGAction {
19581956 return rmn .VRGActionFailover
19591957 case rmn .ActionRelocate :
19601958 return rmn .VRGActionRelocate
1961- case rmn .ActionTestFailover :
1962- return rmn .VRGActionTestFailover
19631959 default :
19641960 return ""
19651961 }
@@ -1972,6 +1968,9 @@ func (d *DRPCInstance) setVRGAction(vrg *rmn.VolumeReplicationGroup) {
19721968 }
19731969
19741970 vrg .Spec .Action = action
1971+ if action == rmn .VRGActionFailover {
1972+ vrg .Spec .DryRun = d .instance .Spec .DryRun
1973+ }
19751974}
19761975
19771976func (d * DRPCInstance ) newVRG (
@@ -2546,25 +2545,11 @@ func (d *DRPCInstance) setDRState(nextState rmn.DRState) {
25462545}
25472546
25482547func (d * DRPCInstance ) adjustPhaseIfTestFailover (nextState rmn.DRState ) rmn.DRState {
2549- if d .instance .Spec .Action == rmn .ActionTestFailover {
2550- return mapPhaseForTestFailover (nextState )
2551- }
2552-
2548+ // With the DryRun approach, we don't need to adjust phases for test failover
2549+ // The progression status (ProgressionTestingFailover) indicates test mode
25532550 return nextState
25542551}
25552552
2556- //nolint:exhaustive
2557- func mapPhaseForTestFailover (nextState rmn.DRState ) rmn.DRState {
2558- switch nextState {
2559- case rmn .FailingOver :
2560- return rmn .TestFailover
2561- case rmn .FailedOver :
2562- return rmn .TestFailedOver
2563- default :
2564- return nextState
2565- }
2566- }
2567-
25682553func updateDRPCProgression (
25692554 drpc * rmn.DRPlacementControl , nextProgression rmn.ProgressionStatus , log logr.Logger ,
25702555) bool {
0 commit comments