Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 2312137: [release-4.17] RDR optimization check for the ODF cluster #1579

Open
wants to merge 1 commit into
base: release-4.17
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"We could not retrieve any information about the managed cluster {{names}}. Check the documentation for potential causes and follow the steps mentioned and try again.": "We could not retrieve any information about the managed cluster {{names}}. Check the documentation for potential causes and follow the steps mentioned and try again.",
"{{ names }} has either an unsupported Data Foundation version or the Data Foundation operator is missing, install or update to Data Foundation {{ version }} or the latest version to enable DR protection.": "{{ names }} has either an unsupported Data Foundation version or the Data Foundation operator is missing, install or update to Data Foundation {{ version }} or the latest version to enable DR protection.",
"{{ names }} is not connected to RHCS": "{{ names }} is not connected to RHCS",
"Cluster not pre-configured for Regional-DR": "Cluster not pre-configured for Regional-DR",
"The selected cluster(s)[{{clusters}}] is not configured for Regional-DR setup. Migrate the OSDs to optimise the cluster for disaster recovery services.": "The selected cluster(s)[{{clusters}}] is not configured for Regional-DR setup. Migrate the OSDs to optimise the cluster for disaster recovery services.",
"Sync schedule": "Sync schedule",
"Replication policy": "Replication policy",
"Information unavailable": "Information unavailable",
Expand Down
9 changes: 7 additions & 2 deletions packages/mco/components/create-dr-policy/create-dr-policy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const CreateDRPolicy: React.FC<{}> = () => {
!!state.policyName &&
!!state.replicationType &&
state.selectedClusters.length === MAX_ALLOWED_CLUSTERS &&
!checkForErrors(state.selectedClusters);
!checkForErrors(state.selectedClusters, state.replicationType);

const loaded = mirrorPeerLoaded && policyLoaded;
const loadedError = mirrorPeerLoadError || policyLoadedError;
Expand Down Expand Up @@ -317,7 +317,12 @@ const CreateDRPolicy: React.FC<{}> = () => {
label={t('Selected clusters')}
>
{state.selectedClusters.map((c, i) => (
<SelectedCluster key={c.name} id={i + 1} cluster={c} />
<SelectedCluster
key={c.name}
id={i + 1}
cluster={c}
replicationType={state.replicationType}
/>
))}
</FormGroup>
)}
Expand Down
2 changes: 2 additions & 0 deletions packages/mco/components/create-dr-policy/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export type StorageClusterInfoType = {
storageSystemNamespacedName: string;
// Ceph FSID to determine RDR/MDR.
cephFSID: string;
// OSDs are migrated for the RDR or not.
isDROptimized: boolean;
};

export type ODFConfigInfoType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ const getODFInfo = (
storageClusterNamespace
);
const cephFSID = odfInfo?.storageCluster?.cephClusterFSID;
const isDROptimized = odfInfo?.storageCluster?.isDROptimized;

return {
odfVersion,
Expand All @@ -105,6 +106,7 @@ const getODFInfo = (
storageClusterNamespacedName,
storageSystemNamespacedName,
cephFSID,
isDROptimized,
},
};
} catch (err) {
Expand All @@ -119,6 +121,7 @@ const getODFInfo = (
storageClusterNamespacedName: '',
storageSystemNamespacedName: '',
cephFSID: '',
isDROptimized: false,
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ const checkSyncPolicyAlreadyExists = (
});

const getClusterErrorInfo = (
selectedClusters: ManagedClusterInfoType[]
selectedClusters: ManagedClusterInfoType[],
replicationType: REPLICATION_TYPE
): ClusterErrorType =>
selectedClusters.reduce(
(acc, cluster) => {
Expand All @@ -62,23 +63,34 @@ const getClusterErrorInfo = (
if (!storageClusterInfo?.cephFSID) {
acc.clustersWithUnsuccessfulODF.push(cluster.name);
}
if (
!storageClusterInfo?.isDROptimized &&
replicationType === REPLICATION_TYPE.ASYNC
) {
acc.clustersWithoutDROptimizedODF.push(cluster.name);
}
return acc;
},
{
unavailableClusters: [],
clustersWithUnsupportedODF: [],
clustersWithoutODF: [],
clustersWithUnsuccessfulODF: [],
clustersWithoutDROptimizedODF: [],
}
);

const getErrorMessage = (
selectedClusters: ManagedClusterInfoType[],
requiredODFVersion: string,
isSyncPolicyFound: boolean,
replicationType: REPLICATION_TYPE,
t: TFunction
): ErrorMessageType => {
const clusterErrorInfo = getClusterErrorInfo(selectedClusters);
const clusterErrorInfo = getClusterErrorInfo(
selectedClusters,
replicationType
);
if (isSyncPolicyFound) {
return {
message: t('Existing DRPolicy detected'),
Expand Down Expand Up @@ -117,6 +129,14 @@ const getErrorMessage = (
names: clusterErrorInfo.clustersWithUnsuccessfulODF.join(' & '),
}),
};
} else if (!!clusterErrorInfo.clustersWithoutDROptimizedODF.length) {
return {
message: t('Cluster not pre-configured for Regional-DR'),
description: t(
'The selected cluster(s)[{{clusters}}] is not configured for Regional-DR setup. Migrate the OSDs to optimise the cluster for disaster recovery services.',
{ clusters: clusterErrorInfo.clustersWithoutDROptimizedODF.join(', ') }
),
};
}
return null;
};
Expand Down Expand Up @@ -171,6 +191,7 @@ export const DRReplicationType: React.FC<DRReplicationTypeProps> = ({
selectedClusters,
requiredODFVersion,
isSyncPolicyFound,
replicationType,
t
);

Expand Down Expand Up @@ -276,6 +297,7 @@ type ClusterErrorType = {
clustersWithUnsupportedODF: string[];
clustersWithoutODF: string[];
clustersWithUnsuccessfulODF: string[];
clustersWithoutDROptimizedODF: string[];
};

type ErrorMessageType = {
Expand Down
15 changes: 11 additions & 4 deletions packages/mco/components/create-dr-policy/selected-cluster-view.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { REPLICATION_TYPE } from '@odf/mco/constants';
import { parseNamespaceName } from '@odf/mco/utils';
import { RedExclamationCircleIcon } from '@odf/shared/status/icons';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
Expand All @@ -16,32 +17,38 @@ import './create-dr-policy.scss';
type SelectedClusterProps = {
id: number;
cluster: ManagedClusterInfoType;
replicationType: REPLICATION_TYPE;
};

export const checkForErrors = (clusters: ManagedClusterInfoType[]) =>
export const checkForErrors = (
clusters: ManagedClusterInfoType[],
replicationType: REPLICATION_TYPE
) =>
clusters.some((cluster) => {
const { isManagedClusterAvailable, odfInfo } = cluster;
const { cephFSID, storageSystemNamespacedName } =
const { cephFSID, storageSystemNamespacedName, isDROptimized } =
odfInfo.storageClusterInfo;
const [storageSystemName] = parseNamespaceName(storageSystemNamespacedName);
return (
!isManagedClusterAvailable ||
!odfInfo?.isValidODFVersion ||
!storageSystemName ||
!cephFSID
!cephFSID ||
(replicationType === REPLICATION_TYPE.ASYNC && !isDROptimized)
);
});

export const SelectedCluster: React.FC<SelectedClusterProps> = ({
id,
cluster,
replicationType,
}) => {
const { t } = useCustomTranslation();
const { name, region, odfInfo } = cluster;
const [storageSystemName] = parseNamespaceName(
odfInfo.storageClusterInfo.storageSystemNamespacedName
);
const anyError = checkForErrors([cluster]);
const anyError = checkForErrors([cluster], replicationType);
return (
<Flex
display={{ default: 'inlineFlex' }}
Expand Down
1 change: 1 addition & 0 deletions packages/mco/types/odf-mco.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export type InfoStorageCluster = {
};
storageProviderEndpoint: string;
cephClusterFSID: string;
isDROptimized: boolean;
};

export type ODFInfoYamlObject = {
Expand Down
Loading