Skip to content

Commit

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

Bug 2239622: [release-4.14-compatibility] remove 'Volume type' from BlockPool create/update form
  • Loading branch information
openshift-merge-robot authored Sep 20, 2023
2 parents 717f382 + 022a4b1 commit 7ffb079
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 107 deletions.
4 changes: 0 additions & 4 deletions cypress/views/block-pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export const populateBlockPoolForm = () => {
cy.byLegacyTestID('replica-dropdown-item')
.contains(`${replicaCount}-way Replication`)
.click();
cy.byTestID('volume-type-dropdown').click();
cy.byTestID('volume-type-dropdown-item')
.contains(volumeType.toLocaleUpperCase())
.click();
cy.byTestID('compression-checkbox').check();
};

Expand Down
3 changes: 1 addition & 2 deletions locales/en/plugin__odf-console.json
Original file line number Diff line number Diff line change
Expand Up @@ -324,8 +324,6 @@
"my-block-pool": "my-block-pool",
"Data protection policy": "Data protection policy",
"Select replication": "Select replication",
"Volume type": "Volume type",
"Select volume type": "Select volume type",
"Compression": "Compression",
"Enable compression": "Enable compression",
"Enabling compression may result in little or no space savings for encrypted or random data. Also, enabling compression may have an impact on I/O performance.": "Enabling compression may result in little or no space savings for encrypted or random data. Also, enabling compression may have an impact on I/O performance.",
Expand All @@ -347,6 +345,7 @@
"{{capacityRatio, number}}:1": "{{capacityRatio, number}}:1",
"Compression ratio indicates the achieved compression on eligible data for this pool": "Compression ratio indicates the achieved compression on eligible data for this pool",
"Storage efficiency": "Storage efficiency",
"Volume type": "Volume type",
"Not available": "Not available",
"Image states info": "Image states info",
"What does each state mean?": "What does each state mean?",
Expand Down
4 changes: 4 additions & 0 deletions packages/ocs/block-pool/body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
.ceph-block-pool__alert {
--pf-global--FontSize--md: 0.8rem;
}

.ceph-block-pool__dropdown-description > div {
white-space: pre-line;
}
87 changes: 1 addition & 86 deletions packages/ocs/block-pool/body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@odf/shared/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { useYupValidationResolver } from '@odf/shared/yup-validation-resolver';
import { useFlag } from '@openshift-console/dynamic-plugin-sdk';
import * as _ from 'lodash-es';
import { useForm } from 'react-hook-form';
import * as Yup from 'yup';
Expand All @@ -33,7 +32,6 @@ import validationRegEx from '../../odf/utils/validation';
import {
CEPH_NS,
OCS_DEVICE_REPLICA,
OCS_POOL_MANAGEMENT,
POOL_PROGRESS,
POOL_STATE,
} from '../constants';
Expand Down Expand Up @@ -80,15 +78,10 @@ export const BlockPoolBody = (props: BlockPoolBodyPros) => {
const { cephCluster, state, dispatch, showPoolStatus, isUpdate } = props;
const { t } = useCustomTranslation();

const isPoolManagementSupported = useFlag(OCS_POOL_MANAGEMENT);
const [storageCluster, storageClusterLoaded, storageClusterLoadError] =
useK8sGet<ListKind<StorageClusterKind>>(StorageClusterModel, null, CEPH_NS);

const [isReplicaOpen, setReplicaOpen] = React.useState(false);
const [isVolumeTypeOpen, setVolumeTypeOpen] = React.useState(false);
const [availableDeviceClasses, setAvailableDeviceClasses] = React.useState(
[]
);

const [data, loaded, loadError] = useK8sList(CephBlockPoolModel, CEPH_NS);

Expand Down Expand Up @@ -152,57 +145,6 @@ export const BlockPoolBody = (props: BlockPoolBodyPros) => {
});
}, [storageCluster, storageClusterLoaded, storageClusterLoadError, dispatch]);

// Volume Type
const deviceClasses = React.useMemo(
() => cephCluster?.status?.storage?.deviceClasses ?? [],
[cephCluster?.status?.storage?.deviceClasses]
);

const setVolumeType = React.useCallback(
(volumeType: string) =>
dispatch({
type: BlockPoolActionType.SET_POOL_VOLUME_TYPE,
payload: volumeType,
}),
[dispatch]
);

React.useEffect(() => {
if (deviceClasses.length && isPoolManagementSupported) {
if (state.volumeType === '') {
// Set default value
const ssdDeviceClass =
deviceClasses.find((deviceClass) => deviceClass.name === 'ssd') || {};
Object.keys(ssdDeviceClass).length
? setVolumeType('ssd')
: setVolumeType(deviceClasses[0].name);
}

// Volume Type dropdown
setAvailableDeviceClasses(
deviceClasses.map((device) => {
return (
<DropdownItem
key={`device-${device?.name}`}
component="button"
id={device?.name}
data-test="volume-type-dropdown-item"
onClick={(e) => setVolumeType(e.currentTarget.id)}
>
{device?.name.toUpperCase()}
</DropdownItem>
);
})
);
}
}, [
deviceClasses,
dispatch,
isPoolManagementSupported,
setVolumeType,
state.volumeType,
]);

// Check storage cluster is in ready state
const isClusterReady: boolean =
cephCluster?.status?.phase === POOL_STATE.READY;
Expand Down Expand Up @@ -249,6 +191,7 @@ export const BlockPoolBody = (props: BlockPoolBodyPros) => {
component="button"
id={replica}
data-test-id="replica-dropdown-item"
className="ceph-block-pool__dropdown-description"
description={warning}
onClick={(e) =>
dispatch({
Expand Down Expand Up @@ -321,34 +264,6 @@ export const BlockPoolBody = (props: BlockPoolBodyPros) => {
id="pool-replica-size"
/>
</div>
{isPoolManagementSupported && (
<div className="form-group ceph-block-pool-body__input">
<label
className="control-label co-required"
htmlFor="pool-volume-type"
>
{t('Volume type')}
</label>
<Dropdown
className="dropdown--full-width"
toggle={
<DropdownToggle
id="toggle-id"
data-test="volume-type-dropdown"
onToggle={() => setVolumeTypeOpen(!isVolumeTypeOpen)}
toggleIndicator={CaretDownIcon}
isDisabled={isUpdate}
>
{state.volumeType.toUpperCase() || t('Select volume type')}
</DropdownToggle>
}
isOpen={isVolumeTypeOpen}
dropdownItems={availableDeviceClasses}
onSelect={() => setVolumeTypeOpen(false)}
id="pool-volume-type"
/>
</div>
)}
<div className="form-group ceph-block-pool-body__input">
<label className="control-label" htmlFor="compression-check">
{t('Compression')}
Expand Down
11 changes: 2 additions & 9 deletions packages/ocs/block-pool/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export enum BlockPoolActionType {
SET_POOL_REPLICA_SIZE = 'SET_POOL_REPLICA_SIZE',
SET_POOL_COMPRESSED = 'SET_POOL_COMPRESSED',
SET_POOL_ARBITER = 'SET_POOL_ARBITER',
SET_POOL_VOLUME_TYPE = 'SET_POOL_VOLUME_TYPE',
SET_FAILURE_DOMAIN = 'SET_FAILURE_DOMAIN',
SET_INPROGRESS = 'SET_INPROGRESS',
SET_ERROR_MESSAGE = 'SET_ERROR_MESSAGE',
Expand All @@ -28,7 +27,8 @@ export const blockPoolInitialState: BlockPoolState = {
replicaSize: '',
isCompressed: false,
isArbiterCluster: false,
volumeType: '',
// this should always be set to 'ssd' (https://bugzilla.redhat.com/show_bug.cgi?id=2239622)
volumeType: 'ssd',
failureDomain: '',
inProgress: false,
errorMessage: '',
Expand All @@ -40,7 +40,6 @@ export type BlockPoolAction =
| { type: BlockPoolActionType.SET_POOL_REPLICA_SIZE; payload: string }
| { type: BlockPoolActionType.SET_POOL_COMPRESSED; payload: boolean }
| { type: BlockPoolActionType.SET_POOL_ARBITER; payload: boolean }
| { type: BlockPoolActionType.SET_POOL_VOLUME_TYPE; payload: string }
| { type: BlockPoolActionType.SET_FAILURE_DOMAIN; payload: string }
| { type: BlockPoolActionType.SET_INPROGRESS; payload: boolean }
| { type: BlockPoolActionType.SET_ERROR_MESSAGE; payload: string };
Expand Down Expand Up @@ -80,12 +79,6 @@ export const blockPoolReducer = (
isArbiterCluster: action.payload,
};
}
case BlockPoolActionType.SET_POOL_VOLUME_TYPE: {
return {
...state,
volumeType: action.payload,
};
}
case BlockPoolActionType.SET_FAILURE_DOMAIN: {
return {
...state,
Expand Down
6 changes: 0 additions & 6 deletions packages/ocs/modals/block-pool/update-block-pool-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,6 @@ const UpdateBlockPoolModal: React.FC<UpdateBlockPoolModalProps> = (props) => {
type: BlockPoolActionType.SET_POOL_COMPRESSED,
payload: poolConfig?.spec.compressionMode === COMPRESSION_ON,
});
// Already existing pool may not have any deviceClass, Default is SSD
poolConfig?.spec.deviceClass &&
dispatch({
type: BlockPoolActionType.SET_POOL_VOLUME_TYPE,
payload: poolConfig?.spec.deviceClass,
});
},
[dispatch]
);
Expand Down

0 comments on commit 7ffb079

Please sign in to comment.