Skip to content

Commit

Permalink
Merge pull request #900 from bipuladh/replica-pool
Browse files Browse the repository at this point in the history
Adds support for single replica pool
  • Loading branch information
openshift-merge-robot authored Jun 27, 2023
2 parents 32f626f + ba1ded8 commit 565168a
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 7 deletions.
3 changes: 3 additions & 0 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,8 @@
"If not labeled, the selected nodes are labeled <2>{{label}}</2> to make them target hosts for Data Foundation's components.": "If not labeled, the selected nodes are labeled <2>{{label}}</2> to make them target hosts for Data Foundation's components.",
"Taint nodes": "Taint nodes",
"Selected nodes will be dedicated to Data Foundation use only": "Selected nodes will be dedicated to Data Foundation use only",
"Add replica-1 pool": "Add replica-1 pool",
"Enabling this feature creates a single replica pool without data replication, increasing the risk of data loss, data corruption, and potential system instability.": "Enabling this feature creates a single replica pool without data replication, increasing the risk of data loss, data corruption, and potential system instability.",
"Select capacity": "Select capacity",
"Select nodes": "Select nodes",
"Select at least 3 nodes preferably in 3 different zones. It is recommended to start with at least 14 CPUs and 34 GiB per node.": "Select at least 3 nodes preferably in 3 different zones. It is recommended to start with at least 14 CPUs and 34 GiB per node.",
Expand Down Expand Up @@ -679,6 +681,7 @@
"Zone: {{zoneCount, number}} zone_other": "Zone: {{zoneCount, number}} zone",
"Arbiter zone: {{zone}}": "Arbiter zone: {{zone}}",
"Taint nodes: {{ocsTaintsStatus}}": "Taint nodes: {{ocsTaintsStatus}}",
"Replica-1 pool: {{singleReplicaPoolStatus}}": "Replica-1 pool: {{singleReplicaPoolStatus}}",
"Security": "Security",
"Encryption: Enabled": "Encryption: Enabled",
"External key management service: {{kmsStatus}}": "External key management service: {{kmsStatus}}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,48 @@ type EnableTaintNodesProps = {
enableTaint: WizardState['capacityAndNodes']['enableTaint'];
};

const EnableSingleReplicaPool: React.FC<EnableSingleReplicaPoolProps> = ({
dispatch,
enableSingleReplicaPool: isSingleReplicaPoolEnabled,
}) => {
const { t } = useCustomTranslation();
return (
<Checkbox
label={t('Add replica-1 pool')}
description={t(
'Enabling this feature creates a single replica pool without data replication, increasing the risk of data loss, data corruption, and potential system instability.'
)}
id="single-replica-pool"
data-checked-state={isSingleReplicaPoolEnabled}
isChecked={isSingleReplicaPoolEnabled}
onChange={() =>
dispatch({
type: 'capacityAndNodes/enableSingleReplicaPool',
payload: !isSingleReplicaPoolEnabled,
})
}
/>
);
};
type EnableSingleReplicaPoolProps = {
dispatch: WizardDispatch;
enableSingleReplicaPool: WizardState['capacityAndNodes']['enableSingleReplicaPool'];
};

type SelectCapacityAndNodesProps = {
dispatch: WizardDispatch;
capacity: WizardState['capacityAndNodes']['capacity'];
nodes: WizardState['nodes'];
enableTaint: WizardState['capacityAndNodes']['enableTaint'];
enableSingleReplicaPool: WizardState['capacityAndNodes']['enableSingleReplicaPool'];
};

const SelectCapacityAndNodes: React.FC<SelectCapacityAndNodesProps> = ({
dispatch,
capacity,
nodes,
enableTaint,
enableSingleReplicaPool,
}) => {
const { t } = useCustomTranslation();

Expand Down Expand Up @@ -193,6 +223,10 @@ const SelectCapacityAndNodes: React.FC<SelectCapacityAndNodesProps> = ({
</GridItem>
</Grid>
<EnableTaintNodes dispatch={dispatch} enableTaint={enableTaint} />
<EnableSingleReplicaPool
dispatch={dispatch}
enableSingleReplicaPool={enableSingleReplicaPool}
/>
</>
);
};
Expand All @@ -205,6 +239,7 @@ const SelectedCapacityAndNodes: React.FC<SelectedCapacityAndNodesProps> = ({
arbiterLocation,
dispatch,
nodes,
enableSingleReplicaPool,
}) => {
const { t } = useCustomTranslation();
const [pv, pvLoaded, pvLoadError] =
Expand Down Expand Up @@ -350,6 +385,10 @@ const SelectedCapacityAndNodes: React.FC<SelectedCapacityAndNodesProps> = ({
</GridItem>
</Grid>
<EnableTaintNodes dispatch={dispatch} enableTaint={enableTaint} />
<EnableSingleReplicaPool
dispatch={dispatch}
enableSingleReplicaPool={enableSingleReplicaPool}
/>
</>
</ErrorHandler>
);
Expand All @@ -359,6 +398,7 @@ type SelectedCapacityAndNodesProps = {
capacity: WizardState['capacityAndNodes']['capacity'];
enableArbiter: WizardState['capacityAndNodes']['enableArbiter'];
enableTaint: WizardState['capacityAndNodes']['enableTaint'];
enableSingleReplicaPool: WizardState['capacityAndNodes']['enableSingleReplicaPool'];
storageClassName: string;
arbiterLocation: WizardState['capacityAndNodes']['arbiterLocation'];
dispatch: WizardDispatch;
Expand All @@ -372,7 +412,13 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
volumeSetName,
nodes,
}) => {
const { capacity, enableArbiter, enableTaint, arbiterLocation } = state;
const {
capacity,
enableArbiter,
enableTaint,
arbiterLocation,
enableSingleReplicaPool,
} = state;

const isNoProvisioner = storageClass.provisioner === NO_PROVISIONER;
const validations = capacityAndNodesValidate(
Expand All @@ -392,13 +438,15 @@ export const CapacityAndNodes: React.FC<CapacityAndNodesProps> = ({
dispatch={dispatch}
nodes={nodes}
capacity={capacity}
enableSingleReplicaPool={enableSingleReplicaPool}
/>
) : (
<SelectCapacityAndNodes
dispatch={dispatch}
enableTaint={enableTaint}
capacity={capacity}
nodes={nodes}
enableSingleReplicaPool={enableSingleReplicaPool}
/>
)}
{!!validations.length &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({
createStorageClass,
nodes,
} = state;
const { capacity, arbiterLocation, enableTaint, enableArbiter } =
capacityAndNodes;
const {
capacity,
arbiterLocation,
enableTaint,
enableArbiter,
enableSingleReplicaPool,
} = capacityAndNodes;
const { encryption, kms, networkType } = securityAndNetwork;
const { deployment, externalStorage, type, enableNFS } = backingStorage;

Expand All @@ -83,6 +88,9 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({

const encryptionStatus = hasEncryption ? t('Enabled') : t('Disabled');
const ocsTaintsStatus = enableTaint ? t('Enabled') : t('Disabled');
const singleReplicaPoolStatus = enableSingleReplicaPool
? t('Enabled')
: t('Disabled');
const nfsStatus = enableNFS ? t('Enabled') : t('Disabled');

const kmsStatus = encryption.advanced
Expand Down Expand Up @@ -165,6 +173,11 @@ export const ReviewAndCreate: React.FC<ReviewAndCreateProps> = ({
})}
</ListItem>
)}
<ListItem>
{t('Replica-1 pool: {{singleReplicaPoolStatus}}', {
singleReplicaPoolStatus,
})}
</ListItem>
</ReviewItem>
)}
{!isRhcs &&
Expand Down
12 changes: 9 additions & 3 deletions packages/odf/components/create-storage-system/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,13 @@ export const createStorageCluster = async (state: WizardState) => {
nodes,
backingStorage,
} = state;
const { capacity, enableArbiter, arbiterLocation, pvCount } =
capacityAndNodes;
const {
capacity,
enableArbiter,
arbiterLocation,
pvCount,
enableSingleReplicaPool,
} = capacityAndNodes;
const { encryption, publicNetwork, clusterNetwork, kms } = securityAndNetwork;
const { type, enableNFS, deployment } = backingStorage;

Expand Down Expand Up @@ -95,7 +100,8 @@ export const createStorageCluster = async (state: WizardState) => {
enableArbiter,
pvCount,
isMCG,
isNFSEnabled
isNFSEnabled,
enableSingleReplicaPool
);
return k8sCreate({ model: OCSStorageClusterModel, data: payload });
};
Expand Down
9 changes: 9 additions & 0 deletions packages/odf/components/create-storage-system/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export const initialState: CreateStorageSystemState = {
},
capacityAndNodes: {
enableArbiter: false,
enableSingleReplicaPool: false,
enableTaint: false,
arbiterLocation: '',
capacity: null,
Expand Down Expand Up @@ -94,6 +95,7 @@ type CreateStorageSystemState = {
connectionDetails: ExternalCephState;
capacityAndNodes: {
enableArbiter: boolean;
enableSingleReplicaPool: boolean;
enableTaint: boolean;
arbiterLocation: string;
// @TODO: Remove union types and use "number" as type.
Expand Down Expand Up @@ -270,6 +272,9 @@ export const reducer: WizardReducer = (prevState, action) => {
case 'capacityAndNodes/enableTaint':
newState.capacityAndNodes.enableTaint = action.payload;
break;
case 'capacityAndNodes/enableSingleReplicaPool':
newState.capacityAndNodes.enableSingleReplicaPool = action.payload;
break;
case 'securityAndNetwork/setKms':
newState.securityAndNetwork.kms = action.payload;
break;
Expand Down Expand Up @@ -362,6 +367,10 @@ export type CreateStorageSystemAction =
type: 'capacityAndNodes/enableTaint';
payload: WizardState['capacityAndNodes']['enableTaint'];
}
| {
type: 'capacityAndNodes/enableSingleReplicaPool';
payload: WizardState['capacityAndNodes']['enableSingleReplicaPool'];
}
| {
type: 'securityAndNetwork/setKms';
payload: WizardState['securityAndNetwork']['kms'];
Expand Down
6 changes: 5 additions & 1 deletion packages/odf/components/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ export const getOCSRequestData = (
stretchClusterChecked?: boolean,
availablePvsCount?: number,
isMCG?: boolean,
isNFSEnabled?: boolean
isNFSEnabled?: boolean,
isSingleReplicaPoolEnabled?: boolean
): StorageClusterKind => {
const scName: string = storageClass.name;
const isNoProvisioner: boolean = storageClass?.provisioner === NO_PROVISIONER;
Expand Down Expand Up @@ -421,6 +422,9 @@ export const getOCSRequestData = (
...Object.assign(
getNetworkField(publicNetwork, clusterNetwork, encryption.inTransit)
),
managedResources: {
cephNonResilientPools: { enable: isSingleReplicaPoolEnabled },
},
};
}

Expand Down

0 comments on commit 565168a

Please sign in to comment.