From 8a3dc36a3c0178cd73b4bfa846f2cefa46f43463 Mon Sep 17 00:00:00 2001 From: Timothy Asir Jeyasingh Date: Fri, 8 May 2026 12:10:18 +0530 Subject: [PATCH] Fix missing external system name Signed-off-by: Timothy Asir Jeyasingh --- .../odf/components/overview/Overview.spec.tsx | 2 + .../ExternalSystemsCard.tsx | 93 ++++++++++++++++--- .../src/hooks/useWatchStorageClusters.ts | 4 + packages/shared/src/models/scale.ts | 2 +- 4 files changed, 87 insertions(+), 14 deletions(-) diff --git a/packages/odf/components/overview/Overview.spec.tsx b/packages/odf/components/overview/Overview.spec.tsx index edcf84663..1a8fbbabc 100644 --- a/packages/odf/components/overview/Overview.spec.tsx +++ b/packages/odf/components/overview/Overview.spec.tsx @@ -34,6 +34,8 @@ jest.mock('@openshift-console/dynamic-plugin-sdk', () => ({ storageClusters: { data: [], loaded: true, loadError: null }, flashSystemClusters: { data: [], loaded: true, loadError: null }, remoteClusters: { data: [], loaded: true, loadError: null }, + sanClusters: { data: [], loaded: true, loadError: null }, + daemons: { data: [], loaded: true, loadError: null }, })), useActivePerspective: jest.fn(() => ''), })); diff --git a/packages/odf/components/overview/external-systems-card/ExternalSystemsCard.tsx b/packages/odf/components/overview/external-systems-card/ExternalSystemsCard.tsx index e2471eb69..3d8cac3be 100644 --- a/packages/odf/components/overview/external-systems-card/ExternalSystemsCard.tsx +++ b/packages/odf/components/overview/external-systems-card/ExternalSystemsCard.tsx @@ -1,9 +1,18 @@ import * as React from 'react'; +import { + IBM_SCALE_LOCAL_CLUSTER_NAME, + SAN_STORAGE_SYSTEM_NAME, +} from '@odf/core/constants'; import { FDF_FLAG } from '@odf/core/redux'; -import { RemoteClusterKind } from '@odf/core/types/scale'; +import { + ClusterKind, + DaemonKind, + RemoteClusterKind, +} from '@odf/core/types/scale'; import { isClusterIgnored, isExternalCluster } from '@odf/core/utils/odf'; import { DASH } from '@odf/shared/constants'; import { useWatchStorageClusters } from '@odf/shared/hooks/useWatchStorageClusters'; +import { getName } from '@odf/shared/selectors'; import { resourceStatus } from '@odf/shared/status/Resource'; import { Status } from '@odf/shared/status/Status'; import { StorageClusterPhase } from '@odf/shared/types/storage'; @@ -81,8 +90,29 @@ const getClustersStatuses = ( ); }; +type IBMScaleOperandKind = RemoteClusterKind | ClusterKind; + +const getIBMScaleExternalSystemNames = ( + remoteClusters: RemoteClusterKind[] = [], + sanClusters: ClusterKind[] = [], + gpfsClusterNameFromDaemon?: string +): string[] => { + const remoteNames = remoteClusters.map((c) => getName(c)); + const sanNames = sanClusters.map((c) => { + if (sanClusters.length === 1 && gpfsClusterNameFromDaemon) { + return gpfsClusterNameFromDaemon; + } + const crName = getName(c); + if (sanClusters.length === 1 && crName === IBM_SCALE_LOCAL_CLUSTER_NAME) { + return SAN_STORAGE_SYSTEM_NAME; + } + return crName; + }); + return [...remoteNames, ...sanNames]; +}; + const getScaleClustersStatuses = ( - clusters: RemoteClusterKind[] = [], + clusters: IBMScaleOperandKind[] = [], t: TFunction ): React.ReactNode => { let [healthy, error, warning] = [0, 0, 0]; @@ -92,11 +122,9 @@ const getScaleClustersStatuses = ( )?.status; if (clusterStatus === 'True') { healthy++; - } - if (clusterStatus === 'False') { + } else if (clusterStatus === 'False') { error++; - } - if (clusterStatus === 'Unknown') { + } else { warning++; } } @@ -129,8 +157,13 @@ const getScaleClustersStatuses = ( }; export const ExternalSystemsCard: React.FC = ({ className }) => { const { t } = useCustomTranslation(); - const { storageClusters, flashSystemClusters, remoteClusters } = - useWatchStorageClusters(); + const { + storageClusters, + flashSystemClusters, + remoteClusters, + sanClusters, + daemons, + } = useWatchStorageClusters(); const navigate = useNavigate(); const isFDF = useFlag(FDF_FLAG); @@ -149,10 +182,37 @@ export const ExternalSystemsCard: React.FC = ({ className }) => { flashSystemClusters?.loaded && !flashSystemClusters?.loadError ? getClustersStatuses(flashSystemClusters?.data, t) : DASH; - const scaleClustersStatuses = - (isFDF ? remoteClusters?.loaded : true) && !remoteClusters?.loadError - ? getScaleClustersStatuses(remoteClusters?.data, t) - : DASH; + + const ibmScaleResourcesLoaded = + !isFDF || + (Boolean(remoteClusters?.loaded) && + Boolean(sanClusters?.loaded) && + Boolean(daemons?.loaded) && + !remoteClusters?.loadError && + !sanClusters?.loadError && + !daemons?.loadError); + + const remoteClustersData = remoteClusters?.data ?? []; + const sanClustersData = sanClusters?.data ?? []; + const gpfsClusterNameFromDaemon = ( + daemons?.data as DaemonKind[] | undefined + )?.[0]?.status?.clusterName; + + const ibmScaleClusters: IBMScaleOperandKind[] = isFDF + ? [...remoteClustersData, ...sanClustersData] + : []; + + const ibmScaleExternalSystemNames = isFDF + ? getIBMScaleExternalSystemNames( + remoteClustersData, + sanClustersData, + gpfsClusterNameFromDaemon + ) + : []; + + const scaleClustersStatuses = ibmScaleResourcesLoaded + ? getScaleClustersStatuses(ibmScaleClusters, t) + : DASH; return ( @@ -169,7 +229,14 @@ export const ExternalSystemsCard: React.FC = ({ className }) => { {t('IBM Scale System')} - {scaleClustersStatuses} + + {ibmScaleExternalSystemNames.length > 0 && ( + + {ibmScaleExternalSystemNames.join(', ')} + + )} + {scaleClustersStatuses} + )} diff --git a/packages/shared/src/hooks/useWatchStorageClusters.ts b/packages/shared/src/hooks/useWatchStorageClusters.ts index ee6169503..0d201d9c8 100644 --- a/packages/shared/src/hooks/useWatchStorageClusters.ts +++ b/packages/shared/src/hooks/useWatchStorageClusters.ts @@ -1,3 +1,4 @@ +import { IBM_SCALE_NAMESPACE } from '@odf/core/constants'; import { FDF_FLAG } from '@odf/core/redux'; import { ClusterKind, @@ -50,6 +51,7 @@ const resources = (isFDF: boolean): WatchK8sResources => ({ kind: RemoteClusterModel.kind, }, isList: true, + namespace: IBM_SCALE_NAMESPACE, }, sanClusters: { groupVersionKind: { @@ -58,6 +60,7 @@ const resources = (isFDF: boolean): WatchK8sResources => ({ kind: ClusterModel.kind, }, isList: true, + namespace: IBM_SCALE_NAMESPACE, }, daemons: { groupVersionKind: { @@ -66,6 +69,7 @@ const resources = (isFDF: boolean): WatchK8sResources => ({ kind: DaemonModel.kind, }, isList: true, + namespace: IBM_SCALE_NAMESPACE, }, } : {}), diff --git a/packages/shared/src/models/scale.ts b/packages/shared/src/models/scale.ts index ad18b6a2c..8d0073e09 100644 --- a/packages/shared/src/models/scale.ts +++ b/packages/shared/src/models/scale.ts @@ -9,7 +9,7 @@ export const ClusterModel: K8sModel = { labelPlural: 'Clusters', crd: true, abbr: 'Cl', - namespaced: false, + namespaced: true, }; export const EncryptionConfigModel: K8sModel = {