Skip to content

Commit

Permalink
Updated the clean up application resource message
Browse files Browse the repository at this point in the history
  • Loading branch information
TimothyAsirJeyasing committed Aug 7, 2024
1 parent 4ed2b85 commit 7e73992
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 53 deletions.
5 changes: 4 additions & 1 deletion locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@
"You are not authorized to complete this action. See your cluster administrator for role-based access control information.": "You are not authorized to complete this action. See your cluster administrator for role-based access control information.",
"Not Authorized": "Not Authorized",
"Empty Page": "Empty Page",
"Clean up application resources on current primary cluster {{ failoverCluster }} to start the relocation.": "Clean up application resources on current primary cluster {{ failoverCluster }} to start the relocation.",
"Cleanup Pending": "Cleanup Pending",
"Relocating to cluster {{ preferredCluster }}": "Relocating to cluster {{ preferredCluster }}",
"In Progress": "In Progress",
"Relocated to cluster {{ preferredCluster }}": "Relocated to cluster {{ preferredCluster }}",
"Completed": "Completed",
"FailingOver to cluster {{ failoverCluster }}": "FailingOver to cluster {{ failoverCluster }}",
"Cleanup of resources requires user attention. Finish cleanup to restart replication.": "Cleanup of resources requires user attention. Finish cleanup to restart replication.",
"Clean up application resources on failed cluster {{ preferredCluster }} to start the replication.": "Clean up application resources on failed cluster {{ preferredCluster }} to start the replication.",
"Pending": "Pending",
"Clean up application resources on failed cluster {{ preferredCluster }}.": "Clean up application resources on failed cluster {{ preferredCluster }}.",
"FailedOver to cluster {{ failoverCluster }}": "FailedOver to cluster {{ failoverCluster }}",
"Unknown": "Unknown",
"Namespaces": "Namespaces",
Expand Down
3 changes: 2 additions & 1 deletion packages/mco/__mocks__/drplacementcontrol.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getName } from '@odf/shared/selectors';
import { LAST_APP_DEPLOYMENT_CLUSTER_ANNOTATION } from '../constants';
import { DRPlacementControlModel } from '../models';
import { DRPlacementControlKind } from '../types';
import { DRPlacementControlKind, Progression } from '../types';
import { createRefFromK8Resource } from '../utils';
import { mockDRClusterEast1 } from './drcluster';
import { mockDRPolicy1 } from './drpolicy';
Expand Down Expand Up @@ -38,6 +38,7 @@ export const mockDRPC1: DRPlacementControlKind = {
},
],
phase: 'Deployed',
progression: Progression.WaitOnUserToCleanUp,
lastGroupSyncTime: '2023-06-06T17:50:56Z',
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import * as React from 'react';
import { DRPC_STATUS } from '@odf/mco/constants';
import { REPLICATION_TYPE } from '@odf/mco/constants';
import { PlacementControlInfo, ProtectedAppsMap } from '@odf/mco/types';
import { getDRStatus } from '@odf/mco/utils';
import { formatTime } from '@odf/shared/details-page/datetime';
Expand Down Expand Up @@ -57,56 +58,83 @@ export const getCurrentActivity = (
failoverCluster: string,
preferredCluster: string,
t: TFunction,
isCleanupPending?: boolean
isCleanupPending?: boolean,
replicationType?: REPLICATION_TYPE
): { description: string; status: string; icon: JSX.Element } => {
const status = currentStatus as DRPC_STATUS;

if (status === DRPC_STATUS.Relocating) {
return {
description: t('Relocating to cluster {{ preferredCluster }}', {
preferredCluster,
}),
status: t('In Progress'),
icon: <InProgressIcon />,
};
} else if (status === DRPC_STATUS.Relocated) {
return {
description: t('Relocated to cluster {{ preferredCluster }}', {
preferredCluster,
}),
status: t('Completed'),
icon: <GreenCheckCircleIcon />,
};
} else if (status === DRPC_STATUS.FailingOver) {
return {
description: t('FailingOver to cluster {{ failoverCluster }}', {
failoverCluster,
}),
status: t('In Progress'),
icon: <InProgressIcon />,
};
} else if (status === DRPC_STATUS.FailedOver) {
return isCleanupPending
? {
description: t(
'Cleanup of resources requires user attention. Finish cleanup to restart replication.'
),
status: t('Pending'),
icon: <PendingIcon />,
}
: {
switch (status) {
case DRPC_STATUS.Relocating:
return isCleanupPending
? {
description: t(
'Clean up application resources on current primary cluster {{ failoverCluster }} to start the relocation.',
{ failoverCluster }
),
status: t('Cleanup Pending'),
icon: <PendingIcon />,
}
: {
description: t('Relocating to cluster {{ preferredCluster }}', {
preferredCluster,
}),
status: t('In Progress'),
icon: <InProgressIcon />,
};

case DRPC_STATUS.Relocated:
return {
description: t('Relocated to cluster {{ preferredCluster }}', {
preferredCluster,
}),
status: t('Completed'),
icon: <GreenCheckCircleIcon />,
};

case DRPC_STATUS.FailingOver:
return {
description: t('FailingOver to cluster {{ failoverCluster }}', {
failoverCluster,
}),
status: t('In Progress'),
icon: <InProgressIcon />,
};

case DRPC_STATUS.FailedOver:
if (isCleanupPending) {
return replicationType === REPLICATION_TYPE.ASYNC
? {
description: t(
'Clean up application resources on failed cluster {{ preferredCluster }} to start the replication.',
{ preferredCluster }
),
status: t('Pending'),
icon: <PendingIcon />,
}
: {
description: t(
'Clean up application resources on failed cluster {{ preferredCluster }}.',
{ preferredCluster }
),
status: t('Pending'),
icon: <PendingIcon />,
};
} else {
return {
description: t('FailedOver to cluster {{ failoverCluster }}', {
failoverCluster,
}),
status: t('Completed'),
icon: <GreenCheckCircleIcon />,
};
} else {
return {
description: t('Unknown'),
status: t('Unknown'),
icon: <GrayUnknownIcon />,
};
}

default:
return {
description: t('Unknown'),
status: t('Unknown'),
icon: <GrayUnknownIcon />,
};
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ export const NamespacesDetails: React.FC<ExpandableComponentProps> = ({

export const EventsDetails: React.FC<ExpandableComponentProps> = ({
application,
syncStatusInfo,
}) => {
const { t } = useCustomTranslation();
const anyOnGoingEvent =
Expand All @@ -339,7 +340,8 @@ export const EventsDetails: React.FC<ExpandableComponentProps> = ({
application.spec?.failoverCluster,
application.spec?.preferredCluster,
t,
isCleanupPending(application)
isCleanupPending(application),
syncStatusInfo.volumeReplicationType
);
const status = [
<StatusIconAndText icon={activity.icon} title={activity.status} />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ export const ProtectedApplicationsListPage: React.FC = () => {
const kubeObjectLastProtectionTime =
app?.status?.lastKubeObjectProtectionTime;
acc[getName(app)] = {
volumeReplicationType: getReplicationType(volumesSchedulingInterval),
volumeReplicationStatus: getReplicationHealth(
volumesLastSyncTime,
volumesSchedulingInterval,
Expand Down
15 changes: 6 additions & 9 deletions packages/mco/components/protected-applications/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,8 @@ import {
REPLICATION_TYPE,
} from '../../constants';
import { DRPlacementControlModel } from '../../models';
import { DRPlacementControlKind } from '../../types';
import {
getVolumeReplicationHealth,
isDRPCAvailable,
isPeerReady,
} from '../../utils';
import { DRPlacementControlKind, Progression } from '../../types';
import { getVolumeReplicationHealth } from '../../utils';
import { DiscoveredApplicationParser as DiscoveredApplicationModal } from '../modals/app-failover-relocate/parser/discovered-application-parser';
import RemoveDisasterRecoveryModal from '../modals/remove-disaster-recovery/remove-disaster-recovery';

Expand Down Expand Up @@ -84,9 +80,9 @@ export const isFailingOrRelocating = (
);

export const isCleanupPending = (drpc: DRPlacementControlKind): boolean =>
drpc?.status?.phase === DRPC_STATUS.FailedOver &&
!isPeerReady(drpc) &&
isDRPCAvailable(drpc);
[DRPC_STATUS.FailedOver, DRPC_STATUS.Relocating].includes(
drpc?.status?.phase as DRPC_STATUS
) && drpc?.status?.progression === Progression.WaitOnUserToCleanUp;

export const getReplicationHealth = (
lastSyncTime: string,
Expand Down Expand Up @@ -142,6 +138,7 @@ export const replicationHealthMap = (

export type SyncStatusInfo = {
volumeReplicationStatus: VOLUME_REPLICATION_HEALTH;
volumeReplicationType: REPLICATION_TYPE;
volumeLastGroupSyncTime: string;
kubeObjectReplicationStatus: VOLUME_REPLICATION_HEALTH;
kubeObjectLastProtectionTime: string;
Expand Down
16 changes: 16 additions & 0 deletions packages/mco/types/ramen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export type DRPlacementControlKind = K8sResourceCommon & {
};
};
phase: string;
progression?: Progression;
// The time of the most recent successful synchronization of all PVCs.
lastGroupSyncTime?: string;
preferredDecision?: {
Expand Down Expand Up @@ -124,3 +125,18 @@ export type DRVolumeReplicationGroupKind = K8sResourceCommon & {
lastGroupSyncTime?: string;
};
};

export enum Progression {
Completed = 'Completed',
Initial = 'Initial',
Deploying = 'Deploying',
Deployed = 'Deployed',
FailingOver = 'FailingOver',
Relocating = 'Relocating',
FailedOver = 'FailedOver',
FailedToFailover = 'FailedToFailover',
WaitOnUserToCleanUp = 'WaitOnUserToCleanUp',
CleaningUp = 'CleaningUp',
FailedToRelocate = 'FailedToRelocate',
WaitForUserAction = 'WaitForUserAction',
}

0 comments on commit 7e73992

Please sign in to comment.