diff --git a/locales/en/plugin__odf-console.json b/locales/en/plugin__odf-console.json index 401d56d72..d8439da22 100644 --- a/locales/en/plugin__odf-console.json +++ b/locales/en/plugin__odf-console.json @@ -1063,7 +1063,7 @@ "Configure monitor count": "Configure monitor count", "To enhance system resilience, align Ceph monitors with the available node failure zones.": "To enhance system resilience, align Ceph monitors with the available node failure zones.", "Failure domains: {{failureDomains}}": "Failure domains: {{failureDomains}}", - "Monitor count: 3": "Monitor count: 3", + "Monitor count: {{monitorCount}}": "Monitor count: {{monitorCount}}", "Recommended monitor count: 5": "Recommended monitor count: 5", "Update count": "Update count", "and": "and", diff --git a/packages/odf/modals/configure-mons/configure-mons.tsx b/packages/odf/modals/configure-mons/configure-mons.tsx index 22a0be3a7..3279b4de3 100644 --- a/packages/odf/modals/configure-mons/configure-mons.tsx +++ b/packages/odf/modals/configure-mons/configure-mons.tsx @@ -2,6 +2,7 @@ import * as React from 'react'; import { NodeKind, NodeModel, + StorageClusterKind, StorageClusterModel, getName, getNamespace, @@ -12,6 +13,8 @@ import { LoadingInline } from '@odf/shared/generic/Loading'; import { ModalBody, ModalFooter, ModalHeader } from '@odf/shared/modals/Modal'; import { k8sPatch } from '@openshift-console/dynamic-plugin-sdk'; import { ModalComponent } from '@openshift-console/dynamic-plugin-sdk/lib/app/modal-support/ModalProvider'; +import { useSelector } from 'react-redux'; +import { compose } from 'redux'; import { Alert, Button, @@ -24,7 +27,7 @@ import { } from '@patternfly/react-core'; import { groupNodesByZones } from '../../components/topology/utils'; import { useSafeK8sGet } from '../../hooks'; -import { useODFNamespaceSelector } from '../../redux'; +import { getODFSystemFlags } from '../../redux'; const patch = [ { @@ -34,8 +37,16 @@ const patch = [ }, ]; +const getStorageClusterName = (store: ReturnType) => + Object.entries(store.systemFlags).find(([, flags]) => flags.isInternalMode); + +const getMonitorCount = (cluster: StorageClusterKind) => + cluster?.spec?.managedResources?.cephCluster?.monCount; + const LowMonAlertModal: ModalComponent = ({ closeModal }) => { - const { odfNamespace } = useODFNamespaceSelector(); + const [namespace, clusterFlags] = useSelector( + compose(getStorageClusterName, getODFSystemFlags) + ); const { t } = useCustomTranslation(); const [errorMessage, setErrorMessage] = React.useState(''); @@ -43,12 +54,19 @@ const LowMonAlertModal: ModalComponent = ({ closeModal }) => { // ToDo (epic 4422) (bipuladh): Update it to use information from the alert. const [storageCluster, storageClusterLoaded, storageCluserLoadError] = - useSafeK8sGet(StorageClusterModel, null, odfNamespace); + useSafeK8sGet( + StorageClusterModel, + clusterFlags.ocsClusterName, + namespace + ); + const [nodes, nodesLoaded, nodesLoadError] = useK8sList(NodeModel); const failureDomains = nodesLoaded && !nodesLoadError ? groupNodesByZones(nodes)?.length : []; const Header = {t('Configure monitor count')}; + const monitorCount = getMonitorCount(storageCluster); + const onSubmit = () => { setProgress(true); k8sPatch({ @@ -63,6 +81,7 @@ const LowMonAlertModal: ModalComponent = ({ closeModal }) => { }) .then(() => { setProgress(false); + closeModal(); }) .catch((err) => { setProgress(false); @@ -102,7 +121,13 @@ const LowMonAlertModal: ModalComponent = ({ closeModal }) => { )} )} - {t('Monitor count: 3')} + + {storageClusterLoaded ? ( + t('Monitor count: {{monitorCount}}', { monitorCount }) + ) : ( + + )} + diff --git a/packages/odf/redux/selectors/odf-system-flags.ts b/packages/odf/redux/selectors/odf-system-flags.ts index c1eaf0bec..b426907b1 100644 --- a/packages/odf/redux/selectors/odf-system-flags.ts +++ b/packages/odf/redux/selectors/odf-system-flags.ts @@ -4,7 +4,7 @@ import { ODFSystemFlagsPayload } from '../actions'; export const odfSystemFlagsReducerName = 'odfSystemFlags'; -const getODFSystemFlags = (state): ODFSystemFlagsPayload => +export const getODFSystemFlags = (state): ODFSystemFlagsPayload => state.plugins?.[reduxReducerScope]?.[odfSystemFlagsReducerName] || {}; export const useODFSystemFlagsSelector = (): ODFSystemFlagsPayload & { diff --git a/packages/shared/src/types/storage.ts b/packages/shared/src/types/storage.ts index 69f1d20c6..96c87a34d 100644 --- a/packages/shared/src/types/storage.ts +++ b/packages/shared/src/types/storage.ts @@ -18,6 +18,11 @@ export type StorageClusterKind = K8sResourceCommon & { nfs?: { enable?: boolean; }; + managedResources?: { + cephCluster: { + monCount: 3 | 5; + }; + }; manageNodes?: boolean; storageDeviceSets?: DeviceSet[]; resourceProfile?: ResourceProfile; diff --git a/plugins/odf/console-extensions.json b/plugins/odf/console-extensions.json index bd109483e..2a0b3c51a 100644 --- a/plugins/odf/console-extensions.json +++ b/plugins/odf/console-extensions.json @@ -684,6 +684,9 @@ "insertAfter": "odfdashboard", "section": "storage", "href": "/odf/storage-clients" + }, + "flags": { + "required": ["PROVIDER_MODE"] } }, { @@ -694,6 +697,9 @@ "component": { "$codeRef": "storageConsumerListPage.ClientListPage" } + }, + "flags": { + "required": ["PROVIDER_MODE"] } } ]