Skip to content

Commit

Permalink
Merge pull request #1519 from SanjalKatiyar/nodes_label
Browse files Browse the repository at this point in the history
Fix nodes' label for ROSA clusters
  • Loading branch information
openshift-merge-bot[bot] authored Aug 6, 2024
2 parents f0bbbaa + d1c7089 commit 4ed2b85
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Card>
Expand Down
6 changes: 3 additions & 3 deletions packages/odf/components/alerts/alert-action-path.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -79,10 +80,11 @@ const onResourceProfileChange = _.curry(
);

const SelectNodesText: React.FC<SelectNodesTextProps> = 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 (
<TextContent>
<Text>{text}</Text>
Expand Down
4 changes: 3 additions & 1 deletion packages/odf/components/create-storage-system/payloads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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[] = [
{
Expand Down
6 changes: 4 additions & 2 deletions packages/odf/constants/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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
Expand Down
9 changes: 4 additions & 5 deletions packages/odf/modals/add-capacity/add-capacity-modal.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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,
Expand Down Expand Up @@ -199,9 +198,9 @@ export const AddCapacityModal: React.FC<AddCapacityModalProps> = ({
}) => {
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:
Expand Down Expand Up @@ -251,7 +250,7 @@ export const AddCapacityModal: React.FC<AddCapacityModalProps> = ({
const replica = getDeviceSetReplica(
isArbiterEnabled,
hasFlexibleScaling,
createWizardNodeState(getCephNodes(nodesData, odfNamespace) as NodeData[])
createWizardNodeState(getCephNodes(nodesData, ocsClusterNs) as NodeData[])
);

const totalCapacityMetric = values?.[0];
Expand Down
2 changes: 1 addition & 1 deletion packages/odf/redux/provider-hooks/useODFNamespace.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import { DEFAULT_STORAGE_NAMESPACE as FALLBACK_NAMESPACE } from '@odf/shared/constants';
import {
SubscriptionModel,
ClusterServiceVersionModel,
Expand All @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion packages/shared/src/constants/common.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit 4ed2b85

Please sign in to comment.