From d1c70899fcecf573e37bc268b5f1ca41e12a7109 Mon Sep 17 00:00:00 2001 From: SanjalKatiyar Date: Tue, 6 Aug 2024 14:03:53 +0530 Subject: [PATCH] Fix nodes label for ROSA clusters --- .../dashboards/persistent-internal/inventory-card.tsx | 4 +++- packages/odf/components/alerts/alert-action-path.tsx | 6 +++--- .../capacity-and-nodes-step/capacity-and-nodes-step.tsx | 6 ++++-- .../odf/components/create-storage-system/payloads.ts | 4 +++- packages/odf/constants/common.ts | 6 ++++-- packages/odf/modals/add-capacity/add-capacity-modal.tsx | 9 ++++----- packages/odf/redux/provider-hooks/useODFNamespace.ts | 2 +- packages/shared/src/constants/common.ts | 2 +- 8 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/ocs/dashboards/persistent-internal/inventory-card.tsx b/packages/ocs/dashboards/persistent-internal/inventory-card.tsx index fc95dda6c..31b15768e 100644 --- a/packages/ocs/dashboards/persistent-internal/inventory-card.tsx +++ b/packages/ocs/dashboards/persistent-internal/inventory-card.tsx @@ -67,7 +67,9 @@ const InventoryCard: React.FC = () => { const pvsData = (resources?.pvs?.data ?? []) as K8sResourceKind[]; const scData = (resources?.sc?.data ?? []) as StorageClassResourceKind[]; - const ocsNodesHref = `/search?kind=${NodeModel.kind}&q=${cephStorageLabel}`; + const ocsNodesHref = `/search?kind=${NodeModel.kind}&q=${cephStorageLabel( + clusterNs + )}`; return ( diff --git a/packages/odf/components/alerts/alert-action-path.tsx b/packages/odf/components/alerts/alert-action-path.tsx index 6f32322c8..8506c7ab8 100644 --- a/packages/odf/components/alerts/alert-action-path.tsx +++ b/packages/odf/components/alerts/alert-action-path.tsx @@ -1,5 +1,5 @@ import { getStorageClusterInNs } from '@odf/core/utils'; -import { CEPH_STORAGE_NAMESPACE } from '@odf/shared/constants'; +import { DEFAULT_STORAGE_NAMESPACE } from '@odf/shared/constants'; import { StorageClusterModel } from '@odf/shared/models'; import { StorageClusterKind } from '@odf/shared/types'; import { k8sList } from '@openshift-console/dynamic-plugin-sdk'; @@ -21,13 +21,13 @@ export const launchClusterExpansionModal = async (alert, launchModal) => { */ const storageCluster = (await k8sList({ model: StorageClusterModel, - queryParams: { ns: CEPH_STORAGE_NAMESPACE }, + queryParams: { ns: DEFAULT_STORAGE_NAMESPACE }, })) as StorageClusterKind[]; launchModal(AddCapacityModal, { isOpen: true, storageCluster: getStorageClusterInNs( storageCluster, - CEPH_STORAGE_NAMESPACE + DEFAULT_STORAGE_NAMESPACE ), }); } catch (e) { diff --git a/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx b/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx index 4c2f60d3e..2d7913004 100644 --- a/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx +++ b/packages/odf/components/create-storage-system/create-storage-system-steps/capacity-and-nodes-step/capacity-and-nodes-step.tsx @@ -37,6 +37,7 @@ import { getDeviceSetCount, getOsdAmount, } from '@odf/core/utils'; +import { DEFAULT_STORAGE_NAMESPACE } from '@odf/shared/constants'; import { FieldLevelHelp } from '@odf/shared/generic/FieldLevelHelp'; import { K8sResourceKind } from '@odf/shared/types'; import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook'; @@ -79,10 +80,11 @@ const onResourceProfileChange = _.curry( ); const SelectNodesText: React.FC = React.memo( - ({ text, systemNamespace }) => { + ({ text }) => { const { t } = useCustomTranslation(); - const label = `cluster.ocs.openshift.io/${systemNamespace}=""`; + // ToDo (epic 4422): Use StorageSystem namespace once we support multiple internal clusters + const label = `cluster.ocs.openshift.io/${DEFAULT_STORAGE_NAMESPACE}=""`; return ( {text} diff --git a/packages/odf/components/create-storage-system/payloads.ts b/packages/odf/components/create-storage-system/payloads.ts index 92dc7419b..73447c2a7 100644 --- a/packages/odf/components/create-storage-system/payloads.ts +++ b/packages/odf/components/create-storage-system/payloads.ts @@ -7,6 +7,7 @@ import { NOOBAA_EXTERNAL_PG_TLS_SECRET_NAME, NOOBA_EXTERNAL_PG_SECRET_NAME, } from '@odf/shared/constants'; +import { DEFAULT_STORAGE_NAMESPACE } from '@odf/shared/constants'; import { StorageClusterModel, ODFStorageSystem, @@ -221,7 +222,8 @@ export const labelNodes = async ( nodes: WizardNodeState[], namespace: string ) => { - const labelPath = `/metadata/labels/cluster.ocs.openshift.io~1${namespace}`; + // ToDo (epic 4422): Use StorageSystem namespace once we support multiple internal clusters + const labelPath = `/metadata/labels/cluster.ocs.openshift.io~1${DEFAULT_STORAGE_NAMESPACE}`; const storageLabel = cephStorageLabel(namespace); const patch: Patch[] = [ { diff --git a/packages/odf/constants/common.ts b/packages/odf/constants/common.ts index 546795772..5027c6063 100644 --- a/packages/odf/constants/common.ts +++ b/packages/odf/constants/common.ts @@ -2,6 +2,7 @@ import { ResourceProfile, ResourceProfileRequirementsMap, } from '@odf/core/types'; +import { DEFAULT_STORAGE_NAMESPACE } from '@odf/shared/constants'; import { Toleration, Taint } from '@odf/shared/types'; import { TFunction } from 'i18next'; @@ -18,8 +19,9 @@ export const OCS_DEVICE_SET_MINIMUM_REPLICAS = 3; export const MINIMUM_NODES = 3; export const SECOND = 1000; -export const cephStorageLabel = (ns: string) => - `cluster.ocs.openshift.io/${ns}`; +// ToDo (epic 4422): Use StorageSystem namespace once we support multiple internal clusters +export const cephStorageLabel = (_ns: string) => + `cluster.ocs.openshift.io/${DEFAULT_STORAGE_NAMESPACE}`; /** * Map between resource profiles and the minimum cpu's and memory (expressed in GiB) required diff --git a/packages/odf/modals/add-capacity/add-capacity-modal.tsx b/packages/odf/modals/add-capacity/add-capacity-modal.tsx index 59f3ab6b7..7636c3a8b 100644 --- a/packages/odf/modals/add-capacity/add-capacity-modal.tsx +++ b/packages/odf/modals/add-capacity/add-capacity-modal.tsx @@ -1,7 +1,6 @@ import * as React from 'react'; import NamespaceSafetyBox from '@odf/core/components/utils/safety-box'; import { useNodesData } from '@odf/core/hooks'; -import { useODFNamespaceSelector } from '@odf/core/redux'; import { NodeData } from '@odf/core/types'; import { getStorageClassDescription } from '@odf/core/utils'; import { getCephNodes } from '@odf/ocs/utils/common'; @@ -17,7 +16,7 @@ import { CommonModalProps } from '@odf/shared/modals/common'; import { ModalBody, ModalFooter, ModalHeader } from '@odf/shared/modals/Modal'; import { StorageClusterModel } from '@odf/shared/models'; import { PersistentVolumeModel, StorageClassModel } from '@odf/shared/models'; -import { getName } from '@odf/shared/selectors'; +import { getName, getNamespace } from '@odf/shared/selectors'; import { StorageClassResourceKind, StorageClusterKind, @@ -199,9 +198,9 @@ export const AddCapacityModal: React.FC = ({ }) => { const { t } = useCustomTranslation(); - const { odfNamespace } = useODFNamespaceSelector(); - + const ocsClusterNs = getNamespace(ocsConfig); const ocsClusterName = getName(ocsConfig); + const [cephTotal, totalError, totalLoading] = useCustomPrometheusPoll({ endpoint: 'api/v1/query' as PrometheusEndpoint, query: @@ -251,7 +250,7 @@ export const AddCapacityModal: React.FC = ({ const replica = getDeviceSetReplica( isArbiterEnabled, hasFlexibleScaling, - createWizardNodeState(getCephNodes(nodesData, odfNamespace) as NodeData[]) + createWizardNodeState(getCephNodes(nodesData, ocsClusterNs) as NodeData[]) ); const totalCapacityMetric = values?.[0]; diff --git a/packages/odf/redux/provider-hooks/useODFNamespace.ts b/packages/odf/redux/provider-hooks/useODFNamespace.ts index b61bd0c85..c83b7bd91 100644 --- a/packages/odf/redux/provider-hooks/useODFNamespace.ts +++ b/packages/odf/redux/provider-hooks/useODFNamespace.ts @@ -1,4 +1,5 @@ import * as React from 'react'; +import { DEFAULT_STORAGE_NAMESPACE as FALLBACK_NAMESPACE } from '@odf/shared/constants'; import { SubscriptionModel, ClusterServiceVersionModel, @@ -13,7 +14,6 @@ import { } from '@openshift-console/dynamic-plugin-sdk'; import { useODFNamespaceDispatch } from '../dispatchers'; -const FALLBACK_NAMESPACE = 'openshift-storage'; const ODF_SUBSCRIPTION_NAME = 'odf-operator'; const CLIENT_SUBSCRIPTION_NAME = 'ocs-client-operator'; diff --git a/packages/shared/src/constants/common.ts b/packages/shared/src/constants/common.ts index 3b0f7601b..112822064 100644 --- a/packages/shared/src/constants/common.ts +++ b/packages/shared/src/constants/common.ts @@ -1,6 +1,6 @@ export const DASH = '-'; export const AVAILABLE = 'Available'; -export const CEPH_STORAGE_NAMESPACE = 'openshift-storage'; +export const DEFAULT_STORAGE_NAMESPACE = 'openshift-storage'; // This hardcoded namespace is only for specific cases, do not use it otherwise. export const ODF_OPERATOR = 'odf-operator'; export const OCS_OPERATOR = 'ocs-operator'; export const ROOK_CEPH_OPERATOR = 'rook-ceph-operator';