diff --git a/locales/en/plugin__odf-console.json b/locales/en/plugin__odf-console.json
index 10c6da658..db3590739 100644
--- a/locales/en/plugin__odf-console.json
+++ b/locales/en/plugin__odf-console.json
@@ -376,9 +376,9 @@
"Estimating {{formattedEta}} to completion": "Estimating {{formattedEta}} to completion",
"Object_one": "Object",
"Object_other": "Object",
+ "NooBaa Bucket": "NooBaa Bucket",
"Buckets": "Buckets",
"Buckets card represents the number of S3 buckets managed on Multicloud Object Gateway and the number of ObjectBucketClaims and the ObjectBuckets managed on both Multicloud Object Gateway and RGW (if deployed).": "Buckets card represents the number of S3 buckets managed on Multicloud Object Gateway and the number of ObjectBucketClaims and the ObjectBuckets managed on both Multicloud Object Gateway and RGW (if deployed).",
- "NooBaa Bucket": "NooBaa Bucket",
"Cluster-wide": "Cluster-wide",
"Any NON Object bucket claims that were created via an S3 client or via the NooBaa UI system.": "Any NON Object bucket claims that were created via an S3 client or via the NooBaa UI system.",
"Break by": "Break by",
@@ -483,13 +483,15 @@
"Optimise cluster for Regional-DR?": "Optimise cluster for Regional-DR?",
"Configure the cluster for a Regional-DR setup by migrating OSDs. Migration may take some time depending on several factors. To learn more about OSDs migration best practices and its consequences refer to the documentation.": "Configure the cluster for a Regional-DR setup by migrating OSDs. Migration may take some time depending on several factors. To learn more about OSDs migration best practices and its consequences refer to the documentation.",
"Optimise": "Optimise",
- "Filesystem name": "Filesystem name",
- "Enter filesystem name": "Enter filesystem name",
- "CephFS filesystem name into which the volume shall be created": "CephFS filesystem name into which the volume shall be created",
"no compression": "no compression",
"with compression": "with compression",
"Replica {{poolSize}} {{compressionText}}": "Replica {{poolSize}} {{compressionText}}",
"Create New Pool": "Create New Pool",
+ "Storage system": "Storage system",
+ "StorageSystem which will be used for storage needs": "StorageSystem which will be used for storage needs",
+ "Filesystem name": "Filesystem name",
+ "Enter filesystem name": "Enter filesystem name",
+ "CephFS filesystem name into which the volume shall be created": "CephFS filesystem name into which the volume shall be created",
"Storage Pool": "Storage Pool",
"Select a Pool": "Select a Pool",
"Storage pool into which volume data shall be stored": "Storage pool into which volume data shall be stored",
@@ -944,7 +946,6 @@
"Num Volumes": "Num Volumes",
"Raw Capacity": "Raw Capacity",
"Add Capacity": "Add Capacity",
- "External": "External",
"Cluster details": "Cluster details",
"Data resiliency": "Data resiliency",
"Nodes": "Nodes",
@@ -954,8 +955,11 @@
"Search...": "Search...",
"Expand to fullscreen": "Expand to fullscreen",
"Exit fullscreen": "Exit fullscreen",
+ "This view is only supported for Internal mode cluster.": "This view is only supported for Internal mode cluster.",
+ "Show message": "Show message",
+ "Hide message": "Hide message",
"Back to main view": "Back to main view",
- "Topology view is not supported for External Mode": "Topology view is not supported for External Mode",
+ "Topology view is not supported for External mode": "Topology view is not supported for External mode",
"No StorageCluster found": "No StorageCluster found",
"Set up a storage cluster to view the topology": "Set up a storage cluster to view the topology",
"A minimal cluster deployment will be performed.": "A minimal cluster deployment will be performed.",
@@ -1008,7 +1012,7 @@
"No StorageClass selected": "No StorageClass selected",
"The Arbiter stretch cluster requires a minimum of 4 nodes (2 different zones, 2 nodes per zone). Please choose a different StorageClass or create a new LocalVolumeSet that matches the minimum node requirement.": "The Arbiter stretch cluster requires a minimum of 4 nodes (2 different zones, 2 nodes per zone). Please choose a different StorageClass or create a new LocalVolumeSet that matches the minimum node requirement.",
"The StorageCluster requires a minimum of 3 nodes. Please choose a different StorageClass or create a new LocalVolumeSet that matches the minimum node requirement.": "The StorageCluster requires a minimum of 3 nodes. Please choose a different StorageClass or create a new LocalVolumeSet that matches the minimum node requirement.",
- "Adding capacity for <1>{{name}}1>, may increase your expenses.": "Adding capacity for <1>{{name}}1>, may increase your expenses.",
+ "Adding capacity for <1>{{ocsClusterName}}1>, may increase your expenses.": "Adding capacity for <1>{{ocsClusterName}}1>, may increase your expenses.",
"Currently Used:": "Currently Used:",
"Add": "Add",
"{{availableCapacity}} / {{replica}} replicas": "{{availableCapacity}} / {{replica}} replicas",
@@ -1159,6 +1163,7 @@
"Receive bandwidth": "Receive bandwidth",
"Node details": "Node details",
"Instance type": "Instance type",
+ "Rack": "Rack",
"External ID": "External ID",
"Node addresses": "Node addresses",
"Machine": "Machine",
@@ -1205,6 +1210,5 @@
"Cannot change resource name (original: \"{{name}}\", updated: \"{{newName}}\").": "Cannot change resource name (original: \"{{name}}\", updated: \"{{newName}}\").",
"Cannot change resource namespace (original: \"{{namespace}}\", updated: \"{{newNamespace}}\").": "Cannot change resource namespace (original: \"{{namespace}}\", updated: \"{{newNamespace}}\").",
"Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").": "Cannot change resource kind (original: \"{{original}}\", updated: \"{{updated}}\").",
- "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").": "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").",
- "Rack": "Rack"
+ "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\").": "Cannot change API group (original: \"{{apiGroup}}\", updated: \"{{newAPIGroup}}\")."
}
diff --git a/packages/mco/components/mco-dashboard/queries.ts b/packages/mco/components/mco-dashboard/queries.ts
index 60093b9a5..e6b5518cd 100644
--- a/packages/mco/components/mco-dashboard/queries.ts
+++ b/packages/mco/components/mco-dashboard/queries.ts
@@ -27,11 +27,11 @@ export const LAST_SYNC_TIME_QUERY = 'ramen_sync_duration_seconds';
export const getLastSyncPerClusterQuery = () =>
`${LAST_SYNC_TIME_QUERY}{${DRPC_OBJECT_TYPE}, ${RAMEN_HUB_OPERATOR_METRICS_SERVICE}}`;
-// ToDo (epic 4422): Need to update as per updates in the metrics
export const CAPACITY_QUERIES = {
- // ToDo (epic 4422): For 4.15, Assuming "managedBy" is unique for each StorageSystem. Need to add "target_namesapce" as an another key.
- [StorageDashboard.TOTAL_CAPACITY_FILE_BLOCK]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (namespace, managedBy, cluster) group_right(storage_system, target_kind, target_namespace) ${TOTAL_CAPACITY_FILE_BLOCK_METRIC}`,
- [StorageDashboard.USED_CAPACITY_FILE_BLOCK]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (namespace, managedBy, cluster) group_right(storage_system, target_kind, target_namespace) ${USED_CAPACITY_FILE_BLOCK_METRIC}`,
+ // ToDo (epic 4422): Need to update as per updates in the metrics (if needed/once confirmed).
+ // Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace") is where system is deployed.
+ [StorageDashboard.TOTAL_CAPACITY_FILE_BLOCK]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (target_namespace, managedBy, cluster) group_right(storage_system, target_kind) (label_replace(${TOTAL_CAPACITY_FILE_BLOCK_METRIC}, "target_namespace", "$1", "namespace", "(.*)"))`,
+ [StorageDashboard.USED_CAPACITY_FILE_BLOCK]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (target_namespace, managedBy, cluster) group_right(storage_system, target_kind) (label_replace(${USED_CAPACITY_FILE_BLOCK_METRIC}, "target_namespace", "$1", "namespace", "(.*)"))`,
};
export const getRBDSnapshotUtilizationQuery = (
@@ -46,10 +46,10 @@ export const getRBDSnapshotUtilizationQuery = (
return queries[queryName];
};
-// ToDo (epic 4422): Need to update as per updates in the metrics
export const STATUS_QUERIES = {
- // ToDo (epic 4422): For 4.15, Assuming "managedBy" is unique for each StorageSystem. Need to add "target_namesapce" as an another key.
- [StorageDashboard.SYSTEM_HEALTH]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (namespace, managedBy, cluster) group_right(storage_system, target_kind, target_namespace) ${SYSTEM_HEALTH_METRIC}`,
+ // ToDo (epic 4422): Need to update as per updates in the metrics (if needed/once confirmed).
+ // Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace") is where system is deployed.
+ [StorageDashboard.SYSTEM_HEALTH]: `(label_replace(odf_system_map, "managedBy", "$1", "target_name", "(.*)")) * on (target_namespace, managedBy, cluster) group_right(storage_system, target_kind) (label_replace(${SYSTEM_HEALTH_METRIC}, "target_namespace", "$1", "namespace", "(.*)"))`,
[StorageDashboard.HEALTH]: SYSTEM_HEALTH_METRIC,
[StorageDashboard.CSV_STATUS]: `csv_succeeded{name=~"${ODF_OPERATOR}.*"}`,
[StorageDashboard.CSV_STATUS_ALL_WHITELISTED]: 'csv_succeeded',
diff --git a/packages/mco/components/mco-dashboard/storage-system/status-card/status-card.tsx b/packages/mco/components/mco-dashboard/storage-system/status-card/status-card.tsx
index 5fb31c7ea..fe94fe5a1 100644
--- a/packages/mco/components/mco-dashboard/storage-system/status-card/status-card.tsx
+++ b/packages/mco/components/mco-dashboard/storage-system/status-card/status-card.tsx
@@ -56,6 +56,8 @@ const setSubSystemMap = (
subSysHealthData: PrometheusResponse,
subSystemMap: SubSystemMap
) =>
+ // ToDo (epic 4422): Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace")
+ // is where system is deployed (update query if needed).
subSysHealthData?.data?.result?.forEach(
(item: PrometheusResult) =>
!item?.metric.managedBy &&
@@ -70,6 +72,8 @@ const setHealthData = (
healthData: SystemHealthMap[],
subSystemMap: SubSystemMap
) =>
+ // ToDo (epic 4422): Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace")
+ // is where system is deployed (update query if needed).
sysHealthData?.data?.result?.forEach((item: PrometheusResult) => {
const { apiGroup } = getGVK(item?.metric.target_kind);
const healthVal = item?.value[1];
diff --git a/packages/mco/components/mco-dashboard/storage-system/system-capacity-card/capacity-card.tsx b/packages/mco/components/mco-dashboard/storage-system/system-capacity-card/capacity-card.tsx
index 551ce076b..31d81e975 100644
--- a/packages/mco/components/mco-dashboard/storage-system/system-capacity-card/capacity-card.tsx
+++ b/packages/mco/components/mco-dashboard/storage-system/system-capacity-card/capacity-card.tsx
@@ -151,12 +151,20 @@ const headerColumns = (t: TFunction) => [
];
const getRow: GetRow = (
- { systemName, targetKind, clusterName, totalValue, usedValue, clusterURL },
+ {
+ systemName,
+ namespace: systemNamespace,
+ targetKind,
+ clusterName,
+ totalValue,
+ usedValue,
+ clusterURL,
+ },
index
) => {
const { apiGroup, apiVersion, kind } = getGVK(targetKind);
const systemKind = referenceForGroupVersionKind(apiGroup)(apiVersion)(kind);
- const systemPath = getDashboardLink(systemKind, systemName);
+ const systemPath = getDashboardLink(systemKind, systemName, systemNamespace);
const isPercentage = !!totalValue;
const progress = isPercentage ? getPercentage(usedValue, totalValue) : 100;
const value = isPercentage
@@ -280,6 +288,8 @@ const SystemCapacityCard: React.FC = () => {
!loadingUsedCapacity && !errorUsedCapacity
? usedCapacity?.data?.result?.reduce(
(acc: CapacityMetricDatumMap, usedMetric: PrometheusResult) => {
+ // ToDo (epic 4422): Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace")
+ // is where system is deployed (update query if needed).
const systemName = usedMetric?.metric?.storage_system;
const namespace = usedMetric?.metric?.target_namespace;
const targetKind = usedMetric?.metric?.target_kind;
@@ -305,6 +315,8 @@ const SystemCapacityCard: React.FC = () => {
!loadingTotalCapacity &&
!errorTotalCapacity &&
totalCapacity?.data?.result?.forEach((totalMetric: PrometheusResult) => {
+ // ToDo (epic 4422): Assuming "namespace" in "odf_system.*"" metrics (except "odf_system_map" which is pushed by ODF opr and already has "target_namespace")
+ // is where system is deployed (update query if needed).
const dataMapKey = getUniqueKey(
totalMetric?.metric?.storage_system,
totalMetric?.metric?.target_namespace,
diff --git a/packages/ocs/block-pool/BlockPoolDetailsPage.tsx b/packages/ocs/block-pool/BlockPoolDetailsPage.tsx
index fad036e7e..5981f0254 100644
--- a/packages/ocs/block-pool/BlockPoolDetailsPage.tsx
+++ b/packages/ocs/block-pool/BlockPoolDetailsPage.tsx
@@ -1,16 +1,15 @@
import * as React from 'react';
-import { useSafeK8sWatchResource } from '@odf/core/hooks';
-import { useODFNamespaceSelector } from '@odf/core/redux';
import DetailsPage from '@odf/shared/details-page/DetailsPage';
import { Kebab } from '@odf/shared/kebab/kebab';
import { ModalKeys } from '@odf/shared/modals/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { referenceForModel } from '@odf/shared/utils';
import { EventStreamWrapped, YAMLEditorWrapped } from '@odf/shared/utils/Tabs';
-import { RouteComponentProps, useLocation } from 'react-router-dom';
+import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
+import { RouteComponentProps, useLocation, useParams } from 'react-router-dom';
import { BlockPoolDashboard } from '../dashboards/block-pool/block-pool-dashboard';
import { CephBlockPoolModel, CephClusterModel } from '../models';
-import { StoragePoolKind } from '../types';
+import { StoragePoolKind, ODFSystemParams } from '../types';
type BlockPoolDetailsPageProps = {
match: RouteComponentProps<{ poolName: string }>['match'];
@@ -30,18 +29,15 @@ export const BlockPoolDetailsPage: React.FC = ({
const { poolName } = match.params;
const location = useLocation();
+ const { namespace: poolNs } = useParams();
const kind = referenceForModel(CephBlockPoolModel);
- const { odfNamespace, isODFNsLoaded, odfNsLoadError } =
- useODFNamespaceSelector();
-
- const [resource, loaded, loadError] =
- useSafeK8sWatchResource((ns: string) => ({
- kind,
- name: poolName,
- namespace: ns,
- isList: false,
- }));
+ const [resource, loaded, loadError] = useK8sWatchResource({
+ kind,
+ name: poolName,
+ namespace: poolNs,
+ isList: false,
+ });
const breadcrumbs = [
{
@@ -65,7 +61,7 @@ export const BlockPoolDetailsPage: React.FC = ({
extraProps={{
resource,
resourceModel: CephBlockPoolModel,
- namespace: odfNamespace,
+ namespace: poolNs,
}}
customKebabItems={[
{
@@ -85,12 +81,12 @@ export const BlockPoolDetailsPage: React.FC = ({
]}
/>
);
- }, [resource, odfNamespace, t]);
+ }, [resource, poolNs, t]);
return (
> = ({
@@ -226,13 +222,15 @@ const RowRenderer: React.FC> = ({
}) => {
const { t } = useCustomTranslation();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const isExternalSS = systemFlags[getNamespace(obj)]?.isExternalMode;
+
const {
poolRawCapacity,
poolCompressionSavings,
storageClasses,
listPagePath,
- cephCluster,
- } = rowData;
+ }: CustomData = rowData;
const { name } = obj.metadata;
const replica = obj.spec?.replicated?.size;
@@ -249,7 +247,6 @@ const RowRenderer: React.FC> = ({
!!compressionMode && compressionMode !== 'none';
const phase = obj?.status?.phase;
- // Hooks
const poolScNames: string[] = React.useMemo(
() => getScNamesUsingPool(storageClasses, name),
[name, storageClasses]
@@ -258,7 +255,6 @@ const RowRenderer: React.FC> = ({
// Details page link
const to = `${listPagePath}/${name}`;
- // Metrics
// {poolRawCapacity: {"pool-1" : size_bytes, "pool-2" : size_bytes, ...}}
const rawCapacity: string = poolRawCapacity?.[name]
? humanizeBinaryBytes(poolRawCapacity?.[name])?.string
@@ -320,7 +316,7 @@ const RowRenderer: React.FC> = ({
>
> = ({
) : (
({
- ceph: {
- kind: referenceForModel(CephClusterModel),
- namespaced: true,
- namespace: ns,
- isList: true,
- },
+const resources = {
sc: {
kind: StorageClassModel.kind,
namespaced: false,
@@ -391,31 +381,28 @@ const resources = (ns: string) => ({
kind: referenceForModel(CephBlockPoolModel),
isList: true,
},
-});
+};
type WatchType = {
sc: StorageClassResourceKind[];
- ceph: K8sResourceKind[];
blockPools: StoragePoolKind[];
};
export const BlockPoolListPage: React.FC = ({}) => {
const { t } = useCustomTranslation();
- const { odfNamespace, isODFNsLoaded, odfNsLoadError, isNsSafe } =
- useODFNamespaceSelector();
-
const location = useLocation();
const listPagePath: string = location.pathname;
- const response = useSafeK8sWatchResources(
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags, areFlagsLoaded, flagsLoadError } =
+ useODFSystemFlagsSelector();
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
+
+ const response = useK8sWatchResources(
resources
) as WatchK8sResults;
- const cephClusters = response.ceph.data;
- const cephLoaded = response.ceph.loaded;
- const cephError = response.ceph.loadError;
-
const storageClasses = response.sc.data;
const scLoaded = response.sc.loaded;
const scError = response.sc.loadError;
@@ -429,26 +416,23 @@ export const BlockPoolListPage: React.FC = ({}) => {
true
);
const poolNames: string[] = blockPools.map((pool) => pool.metadata?.name);
- const memoizedPoolNames = useDeepCompareMemoize(poolNames, true);
- // Metrics
const [poolRawCapacityMetrics, rawCapLoadError, rawCapLoading] =
useCustomPrometheusPoll(
getValidPrometheusPollObj(
{
endpoint: 'api/v1/query' as any,
query: getPoolQuery(
- memoizedPoolNames,
- StorageDashboardQuery.POOL_RAW_CAPACITY_USED
+ poolNames,
+ StorageDashboardQuery.POOL_RAW_CAPACITY_USED,
+ managedByOCS
),
- namespace: odfNamespace,
basePath: usePrometheusBasePath(),
},
- isNsSafe
+ !!poolNames?.length
)
);
- // compression queries
const [compressionSavings, compressionLoadError, compressionLoading] =
useCustomPrometheusPoll(
getValidPrometheusPollObj(
@@ -456,12 +440,12 @@ export const BlockPoolListPage: React.FC = ({}) => {
endpoint: 'api/v1/query' as any,
query: getPoolQuery(
poolNames,
- StorageDashboardQuery.POOL_COMPRESSION_SAVINGS
+ StorageDashboardQuery.POOL_COMPRESSION_SAVINGS,
+ managedByOCS
),
- namespace: odfNamespace,
basePath: usePrometheusBasePath(),
},
- isNsSafe
+ !!poolNames?.length
)
);
@@ -478,13 +462,11 @@ export const BlockPoolListPage: React.FC = ({}) => {
);
return {
storageClasses: memoizedSC ?? [],
- cephCluster: cephClusters?.[0],
poolRawCapacity,
poolCompressionSavings,
listPagePath,
};
}, [
- cephClusters,
compressionLoadError,
compressionLoading,
compressionSavings,
@@ -497,9 +479,9 @@ export const BlockPoolListPage: React.FC = ({}) => {
const loaded =
blockPoolsLoaded &&
- (cephLoaded || scLoaded || !compressionLoading || !rawCapLoading);
+ (areFlagsLoaded || scLoaded || !compressionLoading || !rawCapLoading);
const error =
- cephError ||
+ flagsLoadError ||
scError ||
blockPoolsError ||
compressionLoadError ||
@@ -518,15 +500,15 @@ export const BlockPoolListPage: React.FC = ({}) => {
diff --git a/packages/ocs/block-pool/CreateBlockPool.tsx b/packages/ocs/block-pool/CreateBlockPool.tsx
index 820d8ec2f..930089295 100644
--- a/packages/ocs/block-pool/CreateBlockPool.tsx
+++ b/packages/ocs/block-pool/CreateBlockPool.tsx
@@ -1,24 +1,21 @@
import * as React from 'react';
-import { useSafeK8sWatchResource } from '@odf/core/hooks';
-import { useODFNamespaceSelector } from '@odf/core/redux';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
+import { getResourceInNs as getCephClusterInNs } from '@odf/core/utils';
import { StatusBox } from '@odf/shared/generic/status-box';
-import { useDeepCompareMemoize } from '@odf/shared/hooks/deep-compare-memoize';
import { CephClusterKind } from '@odf/shared/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { referenceForModel } from '@odf/shared/utils';
import {
getAPIVersionForModel,
k8sCreate,
+ useK8sWatchResource,
} from '@openshift-console/dynamic-plugin-sdk';
import { match, useHistory } from 'react-router';
+import { useParams } from 'react-router-dom';
import { Button, Modal } from '@patternfly/react-core';
-import {
- CEPH_EXTERNAL_CR_NAME,
- COMPRESSION_ON,
- POOL_STATE,
-} from '../constants';
+import { COMPRESSION_ON, POOL_STATE } from '../constants';
import { CephBlockPoolModel, CephClusterModel } from '../models';
-import { StoragePoolKind } from '../types';
+import { StoragePoolKind, ODFSystemParams } from '../types';
import { getErrorMessage } from '../utils';
import { BlockPoolBody } from './body';
import { BlockPoolFooter } from './footer';
@@ -53,11 +50,10 @@ export const getPoolKindObj = (
},
});
-export const cephClusterResource = (ns: string) => ({
+export const cephClusterResource = {
kind: referenceForModel(CephClusterModel),
- namespace: ns,
isList: true,
-});
+};
const CreateBlockPool: React.FC = ({
match: blockPoolMatch,
@@ -66,21 +62,24 @@ const CreateBlockPool: React.FC = ({
const { t } = useCustomTranslation();
const history = useHistory();
+ const { namespace: poolNs } = useParams();
const [state, dispatch] = React.useReducer(
blockPoolReducer,
blockPoolInitialState
);
- const [cephClusters, isLoaded, loadError] =
- useSafeK8sWatchResource(cephClusterResource);
- const cephCluster: CephClusterKind = useDeepCompareMemoize(
- cephClusters[0],
- true
- );
+ const [cephClusters, isLoaded, loadError] =
+ useK8sWatchResource(cephClusterResource);
+ // only single cluster per Namespace
+ const cephCluster = getCephClusterInNs(
+ cephClusters,
+ poolNs
+ ) as CephClusterKind;
- const { odfNamespace, isODFNsLoaded, odfNsLoadError } =
- useODFNamespaceSelector();
+ const { systemFlags, areFlagsLoaded, flagsLoadError } =
+ useODFSystemFlagsSelector();
+ const isExternalSS = systemFlags[poolNs]?.isExternalMode;
// OCS create pool page url ends with ~new, ODF create pool page ends with /create/~new
const blockPoolPageUrl = params?.appName
@@ -94,7 +93,7 @@ const CreateBlockPool: React.FC = ({
// Create new pool
const createPool = () => {
if (cephCluster?.status?.phase === POOL_STATE.READY) {
- const poolObj: StoragePoolKind = getPoolKindObj(state, odfNamespace);
+ const poolObj: StoragePoolKind = getPoolKindObj(state, poolNs);
dispatch({ type: BlockPoolActionType.SET_INPROGRESS, payload: true });
k8sCreate({ model: CephBlockPoolModel, data: poolObj })
@@ -118,7 +117,7 @@ const CreateBlockPool: React.FC = ({
});
};
- if (cephCluster?.metadata.name === CEPH_EXTERNAL_CR_NAME) {
+ if (isExternalSS) {
return (
= ({
- {isLoaded && isODFNsLoaded && !loadError && !odfNsLoadError ? (
+ {isLoaded && areFlagsLoaded && !loadError && !flagsLoadError ? (
<>
= ({
>
) : (
)}
diff --git a/packages/ocs/block-pool/body.tsx b/packages/ocs/block-pool/body.tsx
index 76be1d64f..f4b1f63b6 100644
--- a/packages/ocs/block-pool/body.tsx
+++ b/packages/ocs/block-pool/body.tsx
@@ -1,12 +1,12 @@
import * as React from 'react';
-import { useSafeK8sGet, useSafeK8sList } from '@odf/core/hooks';
import { checkArbiterCluster } from '@odf/core/utils';
import {
fieldRequirementsTranslations,
formSettings,
} from '@odf/shared/constants';
+import { useK8sGet, useK8sList } from '@odf/shared/hooks';
import { TextInputWithFieldRequirements } from '@odf/shared/input-with-requirements';
-import { getName } from '@odf/shared/selectors';
+import { getName, getNamespace } from '@odf/shared/selectors';
import {
ListKind,
StorageClusterKind,
@@ -72,12 +72,14 @@ export const BlockPoolBody = (props: BlockPoolBodyPros) => {
const { cephCluster, state, dispatch, showPoolStatus, isUpdate } = props;
const { t } = useCustomTranslation();
+ const poolNs = getNamespace(cephCluster);
+
const [storageCluster, storageClusterLoaded, storageClusterLoadError] =
- useSafeK8sGet>(StorageClusterModel, null);
+ useK8sGet>(StorageClusterModel, null, poolNs);
const [isReplicaOpen, setReplicaOpen] = React.useState(false);
- const [data, loaded, loadError] = useSafeK8sList(CephBlockPoolModel);
+ const [data, loaded, loadError] = useK8sList(CephBlockPoolModel, poolNs);
const { schema, fieldRequirements } = React.useMemo(() => {
const existingNames =
diff --git a/packages/ocs/constants/common.ts b/packages/ocs/constants/common.ts
index b0ecce9c7..94545be5d 100644
--- a/packages/ocs/constants/common.ts
+++ b/packages/ocs/constants/common.ts
@@ -2,7 +2,6 @@ export const PVC_PROVISIONER_ANNOTATION =
'volume.beta.kubernetes.io/storage-provisioner';
export const OCS_OPERATOR = 'ocs-operator';
export const COMPRESSION_ON = 'aggressive';
-export const CEPH_EXTERNAL_CR_NAME = 'ocs-external-storagecluster-cephcluster';
export enum POOL_STATE {
READY = 'Ready',
@@ -34,8 +33,6 @@ export enum CLUSTER_STATUS {
PROGRESSING = 'Progressing',
}
-export const CEPH_INTERNAL_CR_NAME = 'ocs-storagecluster-cephcluster';
-
export const CLUSTER_ID = 'clusterID';
export const PROV_SECRET_NS = 'csi.storage.k8s.io/provisioner-secret-namespace';
export const NODE_SECRET_NS = 'csi.storage.k8s.io/node-stage-secret-namespace';
diff --git a/packages/ocs/dashboards/block-pool/compression-details-card.tsx b/packages/ocs/dashboards/block-pool/compression-details-card.tsx
index 9576a4a97..f9bc683cb 100644
--- a/packages/ocs/dashboards/block-pool/compression-details-card.tsx
+++ b/packages/ocs/dashboards/block-pool/compression-details-card.tsx
@@ -1,4 +1,5 @@
import * as React from 'react';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import { EfficiencyItemBody } from '@odf/shared/dashboards/storage-efficiency/storage-efficiency-card-item';
import {
useCustomPrometheusPoll,
@@ -13,8 +14,10 @@ import {
} from '@odf/shared/utils';
import { DetailsBody } from '@openshift-console/dynamic-plugin-sdk-internal';
import { OverviewDetailItem as DetailItem } from '@openshift-console/plugin-shared';
+import { useParams } from 'react-router-dom';
import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core';
import { getPoolQuery, StorageDashboardQuery } from '../../queries';
+import { ODFSystemParams } from '../../types';
import { getPerPoolMetrics, PoolMetrics } from '../../utils';
import { BlockPoolDashboardContext } from './block-pool-dashboard-context';
@@ -22,18 +25,33 @@ export const CompressionDetailsCard: React.FC = () => {
const { t } = useCustomTranslation();
const { obj } = React.useContext(BlockPoolDashboardContext);
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
+
const compressionMode = obj.spec?.compressionMode;
const compressionEnabled = !!compressionMode && compressionMode !== 'none';
const { name } = obj.metadata;
- // Compression Metrics
const queries = React.useMemo(
() => [
- getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_SAVINGS),
- getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_ELIGIBILITY),
- getPoolQuery([name], StorageDashboardQuery.POOL_COMPRESSION_RATIO),
+ getPoolQuery(
+ [name],
+ StorageDashboardQuery.POOL_COMPRESSION_SAVINGS,
+ managedByOCS
+ ),
+ getPoolQuery(
+ [name],
+ StorageDashboardQuery.POOL_COMPRESSION_ELIGIBILITY,
+ managedByOCS
+ ),
+ getPoolQuery(
+ [name],
+ StorageDashboardQuery.POOL_COMPRESSION_RATIO,
+ managedByOCS
+ ),
],
- [name]
+ [name, managedByOCS]
);
const [poolCompressionSavings, savingsError, savingsLoading] =
diff --git a/packages/ocs/dashboards/block-pool/inventory-card.tsx b/packages/ocs/dashboards/block-pool/inventory-card.tsx
index 568ee758a..fa6e487b3 100644
--- a/packages/ocs/dashboards/block-pool/inventory-card.tsx
+++ b/packages/ocs/dashboards/block-pool/inventory-card.tsx
@@ -32,7 +32,6 @@ export const InventoryCard: React.FC = () => {
const { obj } = React.useContext(BlockPoolDashboardContext);
const { name } = obj.metadata;
- // Hooks
const [scResources, scLoaded, scLoadError] =
useK8sWatchResource(scResource);
const [pvcResources, pvcLoaded, pvcLoadError] =
diff --git a/packages/ocs/dashboards/block-pool/raw-capacity-card.tsx b/packages/ocs/dashboards/block-pool/raw-capacity-card.tsx
index 75c25ebe1..77f4c1564 100644
--- a/packages/ocs/dashboards/block-pool/raw-capacity-card.tsx
+++ b/packages/ocs/dashboards/block-pool/raw-capacity-card.tsx
@@ -1,11 +1,14 @@
import * as React from 'react';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import {
useCustomPrometheusPoll,
usePrometheusBasePath,
} from '@odf/shared/hooks/custom-prometheus-poll';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { getInstantVectorStats } from '@odf/shared/utils';
+import { useParams } from 'react-router-dom';
import { getPoolQuery, StorageDashboardQuery } from '../../queries';
+import { ODFSystemParams } from '../../types';
import {
CapacityCard,
CapacityCardProps,
@@ -17,13 +20,24 @@ export const RawCapacityCard: React.FC = () => {
const { obj } = React.useContext(BlockPoolDashboardContext);
const { name } = obj.metadata;
- // Metrics
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
+
const queries = React.useMemo(
() => [
- getPoolQuery([name], StorageDashboardQuery.POOL_RAW_CAPACITY_USED),
- getPoolQuery([name], StorageDashboardQuery.POOL_MAX_CAPACITY_AVAILABLE),
+ getPoolQuery(
+ [name],
+ StorageDashboardQuery.POOL_RAW_CAPACITY_USED,
+ managedByOCS
+ ),
+ getPoolQuery(
+ [name],
+ StorageDashboardQuery.POOL_MAX_CAPACITY_AVAILABLE,
+ managedByOCS
+ ),
],
- [name]
+ [name, managedByOCS]
);
const [usedCapacityData, usedCapacityLoading, usedCapacityLoadError] =
diff --git a/packages/ocs/dashboards/block-pool/utilization-card.tsx b/packages/ocs/dashboards/block-pool/utilization-card.tsx
index b1efb0b95..73323761f 100644
--- a/packages/ocs/dashboards/block-pool/utilization-card.tsx
+++ b/packages/ocs/dashboards/block-pool/utilization-card.tsx
@@ -1,8 +1,10 @@
import * as React from 'react';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import { PrometheusUtilizationItem } from '@odf/shared/dashboards/utilization-card/prometheus-utilization-item';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { humanizeDecimalBytesPerSec } from '@odf/shared/utils';
import { UtilizationDurationDropdown } from '@openshift-console/dynamic-plugin-sdk-internal';
+import { useParams } from 'react-router-dom';
import {
Grid,
Card,
@@ -11,6 +13,7 @@ import {
CardTitle,
} from '@patternfly/react-core';
import { getPoolQuery, StorageDashboardQuery } from '../../queries';
+import { ODFSystemParams } from '../../types';
import { humanizeIOPS } from '../persistent-internal/utilization-card/utils';
import { BlockPoolDashboardContext } from './block-pool-dashboard-context';
@@ -19,6 +22,10 @@ export const UtilizationCard: React.FC = () => {
const { obj } = React.useContext(BlockPoolDashboardContext);
const { name } = obj.metadata;
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
+
return (
@@ -32,7 +39,8 @@ export const UtilizationCard: React.FC = () => {
title={t('IOPS')}
utilizationQuery={getPoolQuery(
[name],
- StorageDashboardQuery.POOL_UTILIZATION_IOPS_QUERY
+ StorageDashboardQuery.POOL_UTILIZATION_IOPS_QUERY,
+ managedByOCS
)}
humanizeValue={humanizeIOPS}
/>
@@ -40,7 +48,8 @@ export const UtilizationCard: React.FC = () => {
title={t('Throughput')}
utilizationQuery={getPoolQuery(
[name],
- StorageDashboardQuery.POOL_UTILIZATION_THROUGHPUT_QUERY
+ StorageDashboardQuery.POOL_UTILIZATION_THROUGHPUT_QUERY,
+ managedByOCS
)}
humanizeValue={humanizeDecimalBytesPerSec}
/>
diff --git a/packages/ocs/dashboards/network-file-system/status-card/status-card.tsx b/packages/ocs/dashboards/network-file-system/status-card/status-card.tsx
index 94842a86b..3ada7018e 100644
--- a/packages/ocs/dashboards/network-file-system/status-card/status-card.tsx
+++ b/packages/ocs/dashboards/network-file-system/status-card/status-card.tsx
@@ -1,6 +1,5 @@
import * as React from 'react';
-import { useSafeK8sWatchResource } from '@odf/core/hooks';
-import { K8sResourceObj } from '@odf/core/types';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import HealthItem from '@odf/shared/dashboards/status-card/HealthItem';
import { PodModel } from '@odf/shared/models';
import { PodKind } from '@odf/shared/types';
@@ -10,24 +9,32 @@ import {
getPodStatus,
getPodHealthState,
} from '@odf/shared/utils';
+import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
+import { useParams } from 'react-router-dom';
import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core';
+import { ODFSystemParams } from '../../../types';
-const nfsPodResource: K8sResourceObj = (ns) => ({
+const nfsPodResource = (clusterNs: string, clusterName: string) => ({
isList: true,
kind: referenceForModel(PodModel),
- namespace: ns,
+ namespace: clusterNs,
selector: {
matchLabels: {
app: 'rook-ceph-nfs',
- ceph_nfs: 'ocs-storagecluster-cephnfs',
+ ceph_nfs: `${clusterName}-cephnfs`,
},
},
});
export const StatusCard: React.FC = () => {
const { t } = useCustomTranslation();
- const [nfsPods, nfsPodsLoaded, nfsPodsLoadError] =
- useSafeK8sWatchResource(nfsPodResource);
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const clusterName = systemFlags[clusterNs]?.ocsClusterName;
+
+ const [nfsPods, nfsPodsLoaded, nfsPodsLoadError] = useK8sWatchResource<
+ PodKind[]
+ >(nfsPodResource(clusterNs, clusterName));
const serverHealthState = getPodHealthState(
getPodStatus(nfsPods?.[0]),
diff --git a/packages/ocs/dashboards/object-service/activity-card/activity-card.tsx b/packages/ocs/dashboards/object-service/activity-card/activity-card.tsx
index 78ce50305..69864832d 100644
--- a/packages/ocs/dashboards/object-service/activity-card/activity-card.tsx
+++ b/packages/ocs/dashboards/object-service/activity-card/activity-card.tsx
@@ -1,6 +1,6 @@
import * as React from 'react';
-import { RGW_FLAG } from '@odf/core/features';
-import { useSafeK8sWatchResource } from '@odf/core/hooks';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
+import { odfSystemFlagsPayload } from '@odf/core/redux/actions';
import { secretResource } from '@odf/core/resources';
import {
useCustomPrometheusPoll,
@@ -10,50 +10,63 @@ import { EventModel } from '@odf/shared/models';
import { K8sResourceKind } from '@odf/shared/types';
import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { getResiliencyProgress } from '@odf/shared/utils';
-import {
- useK8sWatchResource,
- useFlag,
-} from '@openshift-console/dynamic-plugin-sdk';
+import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import {
ActivityBody,
RecentEventsBody,
OngoingActivityBody,
} from '@openshift-console/dynamic-plugin-sdk-internal';
import { EventKind } from '@openshift-console/dynamic-plugin-sdk-internal/lib/api/internal-types';
+import { useParams } from 'react-router-dom';
import { Card, CardHeader, CardTitle } from '@patternfly/react-core';
import {
dataResiliencyQueryMap,
ObjectServiceDashboardQuery,
} from '../../../queries';
+import { ODFSystemParams } from '../../../types';
import { isObjectStorageEvent, decodeRGWPrefix } from '../../../utils';
import './activity-card.scss';
const eventsResource = { isList: true, kind: EventModel.kind };
-const RecentEvent: React.FC = () => {
+type ActivityProps = {
+ systemFlags: odfSystemFlagsPayload['systemFlags'];
+ clusterNs: string;
+};
+
+const RecentEvent: React.FC = ({ systemFlags, clusterNs }) => {
+ const isRGWSupported = systemFlags[clusterNs]?.isRGWAvailable;
+ const isMCGSupported = systemFlags[clusterNs]?.isNoobaaAvailable;
+
const [data, loaded, loadError] =
useK8sWatchResource(eventsResource);
return (
);
};
-const OngoingActivity: React.FC = () => {
- const [data, loaded, loadError] =
- useSafeK8sWatchResource(secretResource);
- const isRGWSupported = useFlag(RGW_FLAG);
+const OngoingActivity: React.FC = ({
+ systemFlags,
+ clusterNs,
+}) => {
+ const isRGWSupported = systemFlags[clusterNs]?.isRGWAvailable;
+ const isMCGSupported = systemFlags[clusterNs]?.isNoobaaAvailable;
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
+
+ const [data, loaded, loadError] = useK8sWatchResource(
+ secretResource(clusterNs)
+ );
const rgwPrefix = React.useMemo(
() => (isRGWSupported && loaded && !loadError ? decodeRGWPrefix(data) : ''),
[data, loaded, loadError, isRGWSupported]
);
- const rgwResiliencyQuery =
- dataResiliencyQueryMap[
- ObjectServiceDashboardQuery.RGW_REBUILD_PROGRESS_QUERY
- ](rgwPrefix);
+ const rgwResiliencyQuery = dataResiliencyQueryMap[
+ ObjectServiceDashboardQuery.RGW_REBUILD_PROGRESS_QUERY
+ ](rgwPrefix, managedByOCS);
const [progress, progressError] = useCustomPrometheusPoll({
query: dataResiliencyQueryMap.MCG_REBUILD_PROGRESS_QUERY,
@@ -73,7 +86,7 @@ const OngoingActivity: React.FC = () => {
const prometheusActivities = [];
- if (getResiliencyProgress(progress) < 1) {
+ if (isMCGSupported && getResiliencyProgress(progress) < 1) {
prometheusActivities.push({
results: [progress, eta],
loader: () =>
@@ -96,7 +109,7 @@ const OngoingActivity: React.FC = () => {
return (
{
const ActivityCard: React.FC = () => {
const { t } = useCustomTranslation();
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+
return (
{t('Activity')}
-
-
+
+
);
diff --git a/packages/ocs/dashboards/object-service/buckets-card/buckets-card.tsx b/packages/ocs/dashboards/object-service/buckets-card/buckets-card.tsx
index a488cc5cf..5f8690867 100644
--- a/packages/ocs/dashboards/object-service/buckets-card/buckets-card.tsx
+++ b/packages/ocs/dashboards/object-service/buckets-card/buckets-card.tsx
@@ -4,6 +4,7 @@ import {
NooBaaObjectBucketClaimModel,
NooBaaObjectBucketModel,
} from '@odf/core/models';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import { FieldLevelHelp } from '@odf/shared/generic/FieldLevelHelp';
import {
useCustomPrometheusPoll,
@@ -21,7 +22,9 @@ import {
InventoryItemBody,
} from '@openshift-console/dynamic-plugin-sdk';
import { ResourceInventoryItem } from '@openshift-console/dynamic-plugin-sdk-internal';
+import { useParams } from 'react-router-dom';
import { Card, CardBody, CardHeader, CardTitle } from '@patternfly/react-core';
+import { ODFSystemParams } from '../../../types';
import { BucketsTitle } from './buckets-card-item';
import { getObcStatusGroups, getObStatusGroups } from './utils';
import './buckets-card.scss';
@@ -89,15 +92,9 @@ const ObjectInventoryItem: React.FC = ({
);
};
-const ObjectDashboardBucketsCard: React.FC<{}> = () => {
+const ObjectInventoryItem_: React.FC = () => {
const { t } = useCustomTranslation();
- const [obcData, obcLoaded, obcLoadError] = useK8sWatchResource<
- K8sResourceKind[]
- >(objectBucketClaimsResource);
- const [obData, obLoaded, obLoadError] =
- useK8sWatchResource(objectBucketResource);
-
const [noobaaCount, noobaaCountError] = useCustomPrometheusPoll({
query: BucketsCardQueries.BUCKETS_COUNT,
endpoint: 'api/v1/query' as any,
@@ -121,6 +118,48 @@ const ObjectDashboardBucketsCard: React.FC<{}> = () => {
getGaugeValue(unhealthyNoobaaBuckets)
);
+ return (
+ (
+
+ ),
+ [noobaaObjectsCount, noobaaObjectsCountError]
+ )}
+ >
+ {unhealthyNoobaaBucketsCount > 0 && (
+ <>
+
+
+ {unhealthyNoobaaBucketsCount}
+
+ >
+ )}
+
+ );
+};
+
+const ObjectDashboardBucketsCard: React.FC<{}> = () => {
+ const { t } = useCustomTranslation();
+
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const isMCGSupported = systemFlags[clusterNs]?.isNoobaaAvailable;
+
+ const [obcData, obcLoaded, obcLoadError] = useK8sWatchResource<
+ K8sResourceKind[]
+ >(objectBucketClaimsResource);
+ const [obData, obLoaded, obLoadError] =
+ useK8sWatchResource(objectBucketResource);
+
return (
@@ -134,31 +173,7 @@ const ObjectDashboardBucketsCard: React.FC<{}> = () => {
- (
-
- ),
- [noobaaObjectsCount, noobaaObjectsCountError]
- )}
- >
- {unhealthyNoobaaBucketsCount > 0 && (
- <>
-
-
- {unhealthyNoobaaBucketsCount}
-
- >
- )}
-
+ {isMCGSupported && }
{
const originalModule = jest.requireActual<
typeof import('@openshift-console/dynamic-plugin-sdk/lib/extensions')
@@ -28,7 +30,18 @@ jest.mock('@odf/core/hooks', () => ({
}));
jest.mock('@odf/core/redux', () => ({
- useODFNamespaceSelector: () => ({ odfNamespace: '' }),
+ ...jest.requireActual('@odf/core/redux'),
+ useODFNamespaceSelector: () => ({ odfNamespace: testNamespace }),
+ useODFSystemFlagsSelector: () => ({
+ systemFlags: {
+ [testNamespace]: { isRGWAvailable: true, isNoobaaAvailable: true },
+ },
+ }),
+}));
+
+jest.mock('react-router-dom', () => ({
+ ...jest.requireActual('react-router-dom'),
+ useParams: () => ({ namespace: testNamespace }),
}));
describe('Capacity Breakdown Card', () => {
diff --git a/packages/ocs/dashboards/object-service/capacity-breakdown/capacity-breakdown-card.tsx b/packages/ocs/dashboards/object-service/capacity-breakdown/capacity-breakdown-card.tsx
index d7bfed35c..93d2d3321 100644
--- a/packages/ocs/dashboards/object-service/capacity-breakdown/capacity-breakdown-card.tsx
+++ b/packages/ocs/dashboards/object-service/capacity-breakdown/capacity-breakdown-card.tsx
@@ -1,7 +1,6 @@
import * as React from 'react';
-import { RGW_FLAG } from '@odf/core/features';
-import { useSafeK8sWatchResource } from '@odf/core/hooks';
import { useODFNamespaceSelector } from '@odf/core/redux';
+import { useODFSystemFlagsSelector } from '@odf/core/redux';
import { secretResource } from '@odf/core/resources';
import { BreakdownCardBody } from '@odf/shared/dashboards/breakdown-card/breakdown-body';
import { LabelPadding } from '@odf/shared/dashboards/breakdown-card/breakdown-chart';
@@ -18,12 +17,10 @@ import { useCustomTranslation } from '@odf/shared/useCustomTranslationHook';
import { DataPoint, getInstantVectorStats } from '@odf/shared/utils';
import { humanizeBinaryBytes, referenceForModel } from '@odf/shared/utils';
import { isFunctionThenApply } from '@odf/shared/utils';
-import {
- useK8sWatchResource,
- useFlag,
-} from '@openshift-console/dynamic-plugin-sdk';
+import { useK8sWatchResource } from '@openshift-console/dynamic-plugin-sdk';
import { K8sModel } from '@openshift-console/dynamic-plugin-sdk/lib/api/common-types';
import * as _ from 'lodash-es';
+import { useParams } from 'react-router-dom';
import {
Select,
SelectGroup,
@@ -40,6 +37,7 @@ import {
CapacityBreakdown,
} from '../../../constants';
import { breakdownQueryMapMCG } from '../../../queries';
+import { ODFSystemParams } from '../../../types';
import { decodeRGWPrefix, getStackChartStats } from '../../../utils';
import './capacity-breakdown-card.scss';
@@ -295,21 +293,28 @@ const BreakdownCard: React.FC = () => {
);
const [isOpenServiceSelect, setServiceSelect] = React.useState(false);
const [isOpenBreakdownSelect, setBreakdownSelect] = React.useState(false);
- const isRGWSupported = useFlag(RGW_FLAG);
- const prevRGWVal = React.useRef(null);
+
+ const { namespace: clusterNs } = useParams();
+ const { systemFlags } = useODFSystemFlagsSelector();
+ const isRGWSupported = systemFlags[clusterNs]?.isRGWAvailable;
+ const isMCGSupported = systemFlags[clusterNs]?.isNoobaaAvailable;
+ const managedByOCS = systemFlags[clusterNs]?.ocsClusterName;
React.useEffect(() => {
- if (isRGWSupported !== prevRGWVal.current) {
- prevRGWVal.current = isRGWSupported;
- if (isRGWSupported) {
- setServiceType(ServiceType.ALL);
- setMetricType(CapacityBreakdown.defaultMetrics[ServiceType.ALL]);
- }
+ if (isRGWSupported && isMCGSupported) {
+ setServiceType(ServiceType.ALL);
+ setMetricType(CapacityBreakdown.defaultMetrics[ServiceType.ALL]);
+ } else if (isMCGSupported) {
+ setServiceType(ServiceType.MCG);
+ setMetricType(CapacityBreakdown.defaultMetrics[ServiceType.MCG]);
+ } else if (isRGWSupported) {
+ setServiceType(ServiceType.RGW);
+ setMetricType(CapacityBreakdown.defaultMetrics[ServiceType.RGW]);
}
- }, [isRGWSupported]);
+ }, [isRGWSupported, isMCGSupported]);
const [secretData, secretLoaded, secretLoadError] =
- useSafeK8sWatchResource(secretResource);
+ useK8sWatchResource(secretResource(clusterNs));
const rgwPrefix = React.useMemo(
() =>
isRGWSupported && secretLoaded && !secretLoadError
@@ -328,11 +333,11 @@ const BreakdownCard: React.FC = () => {
CapacityBreakdown.defaultMetrics[serviceType]
];
return {
- queries: isFunctionThenApply(q)(rgwPrefix),
+ queries: isFunctionThenApply(q)(rgwPrefix, managedByOCS),
model: mo,
metric: me,
};
- }, [serviceType, metricType, rgwPrefix]);
+ }, [serviceType, metricType, rgwPrefix, managedByOCS]);
const prometheusQueries = React.useMemo(
() => Object.values(queries) as string[],
@@ -421,7 +426,7 @@ const BreakdownCard: React.FC = () => {
- {isRGWSupported && (
+ {isRGWSupported && isMCGSupported && (