Skip to content

Commit

Permalink
Merge pull request #1170 from openshift-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…1153-to-release-4.15-compatibility

Bug 2240908: [release-4.15-compatible] [RDR] [UI] DR UI allows Relocate and Failover to same peer causing the failover stuck
  • Loading branch information
openshift-merge-bot[bot] authored Jan 11, 2024
2 parents d3c5d0f + e5c0bb7 commit f572644
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,13 @@ export const ArogoApplicationSetModal = (
drPolicyName: getName(drPolicy),
drPlacementControlName: getName(drPlacementControl),
targetClusterName: getName(targetDRCluster),
primaryClusterName: getName(primaryCluster),
isTargetClusterAvailable: !!targetClusterCondition,
targetClusterAvailableTime:
targetClusterCondition?.lastTransitionTime,
isPrimaryClusterAvailable: !!primaryClusterCondition,
isDRActionReady: checkDRActionReadiness(drPlacementControl, action),
snapshotTakenTime: drPlacementControl?.status?.lastGroupSyncTime,
preferredCluster: drPlacementControl?.spec?.preferredCluster,
failoverCluster: drPlacementControl?.spec?.failoverCluster,
replicationType: findDRType(drClusters),
isTargetClusterFenced: isDRClusterFenced(targetDRCluster),
isPrimaryClusterFenced: isDRClusterFenced(primaryDRCluster),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,8 @@ export type PlacementProps = Partial<{
drPlacementControlName: string;
targetClusterName: string;
targetClusterAvailableTime: string;
primaryClusterName: string;
snapshotTakenTime: string;
failoverCluster: string;
preferredCluster: string;
isTargetClusterAvailable: boolean;
isPrimaryClusterAvailable: boolean;
isDRActionReady: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export const FailoverRelocateModal: React.FC<FailoverRelocateModalProps> = (

const onClick = () => {
setFooterStatus(ModalFooterStatus.INPROGRESS);
// Prefered cluster and failover cluster should not be same for failover and relocate.
const patch = [
{
op: 'replace',
Expand All @@ -67,11 +68,19 @@ export const FailoverRelocateModal: React.FC<FailoverRelocateModalProps> = (
},
{
op: 'replace',
path:
path: '/spec/failoverCluster',
value:
action === DRActionType.FAILOVER
? '/spec/failoverCluster'
: '/spec/preferredCluster',
value: placement?.targetClusterName,
? placement?.targetClusterName
: placement?.primaryClusterName,
},
{
op: 'replace',
path: '/spec/preferredCluster',
value:
action === DRActionType.FAILOVER
? placement?.primaryClusterName
: placement?.targetClusterName,
},
];
k8sPatch({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ export const SubscriptionFailoverRelocateModal: React.FC<FailoverRelocateModalPr
const onClick = () => {
updateModalStatus(ModalFooterStatus.INPROGRESS);
const promises: Promise<K8sResourceKind>[] = [];
const targetClusterName =
state.selectedTargetCluster.clusterInfo.clusterName;
const primaryClusterName = state.selectedDRPolicy.drClusters.find(
(drCluster) => drCluster !== targetClusterName
);
state.drPolicyControlState.forEach((acmToDRState) => {
if (
state.selectedSubsGroups.includes(
Expand All @@ -127,15 +132,21 @@ export const SubscriptionFailoverRelocateModal: React.FC<FailoverRelocateModalPr
path: '/spec/action',
value: action,
},
state.actionType === DRActionType.RELOCATE && {
{
op: 'replace',
path: '/spec/preferredCluster',
value: state.selectedTargetCluster.clusterInfo.clusterName,
path: '/spec/failoverCluster',
value:
action === DRActionType.FAILOVER
? targetClusterName
: primaryClusterName,
},
state.actionType === DRActionType.FAILOVER && {
{
op: 'replace',
path: '/spec/failoverCluster',
value: state.selectedTargetCluster.clusterInfo.clusterName,
path: '/spec/preferredCluster',
value:
action === DRActionType.FAILOVER
? primaryClusterName
: targetClusterName,
},
];
promises.push(
Expand Down

0 comments on commit f572644

Please sign in to comment.