Skip to content

Commit

Permalink
Handle conflicts when starting failover or relocate
Browse files Browse the repository at this point in the history
Fix random failures like:

    actions_test.go:53: Operation cannot be fulfilled on
    drplacementcontrols.ramendr.openshift.io "subscr-deploy-rbd-busybox":
    the object has been modified; please apply your changes to the latest
    version and try again

Signed-off-by: Nir Soffer <[email protected]>
  • Loading branch information
nirs authored and raghavendra-talur committed Oct 23, 2024
1 parent ec7c087 commit 797475c
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions e2e/dractions/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,6 @@ func waitAndUpdateDRPC(client client.Client, namespace, drpcName string, action
return err
}

drpc, err := getDRPC(client, namespace, drpcName)
if err != nil {
return err
}

drPolicyName := util.DefaultDRPolicyName

drpolicy, err := util.GetDRPolicy(client, drPolicyName)
Expand All @@ -182,16 +177,23 @@ func waitAndUpdateDRPC(client client.Client, namespace, drpcName string, action
return err
}

drpc.Spec.Action = action
if action == ramen.ActionFailover {
drpc.Spec.FailoverCluster = targetCluster
} else {
drpc.Spec.PreferredCluster = targetCluster
}

util.Ctx.Log.Info("update drpc " + drpcName + " " + strings.ToLower(string(action)) + " to " + targetCluster)

return updateDRPC(client, drpc)
return retry.RetryOnConflict(retry.DefaultBackoff, func() error {
drpc, err := getDRPC(client, namespace, drpcName)
if err != nil {
return err
}

drpc.Spec.Action = action
if action == ramen.ActionFailover {
drpc.Spec.FailoverCluster = targetCluster
} else {
drpc.Spec.PreferredCluster = targetCluster
}

return updateDRPC(client, drpc)
})
}

func GetNamespace(d deployers.Deployer, w workloads.Workload) string {
Expand Down

0 comments on commit 797475c

Please sign in to comment.