Skip to content

Commit

Permalink
Merge pull request #7888 from SanjalKatiyar/fix_ocs_zone_label
Browse files Browse the repository at this point in the history
Bug 1916882: OCS 4.7 wizard does not show zone when zone's are added manually
  • Loading branch information
openshift-merge-robot committed Jan 24, 2021
2 parents d40b17d + 570b133 commit bf732d3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { humanizeCpuCores, ResourceLink } from '@console/internal/components/uti
import { NodeKind } from '@console/internal/module/k8s';
import { Table } from '@console/internal/components/factory';
import { IRow, sortable } from '@patternfly/react-table';
import { getConvertedUnits, nodesWithoutTaints } from '../../utils/install';
import { getConvertedUnits, nodesWithoutTaints, getZone } from '../../utils/install';
import { cephStorageLabel } from '../../selectors';
import { ZONE_LABELS } from '../../constants';
import { GetRows, NodeTableProps } from './types';
import './ocs-install.scss';

Expand Down Expand Up @@ -45,7 +44,6 @@ const getRows: GetRows = (
const roles = getNodeRoles(node).sort();
const cpuSpec: string = getNodeCPUCapacity(node);
const memSpec: string = getNodeAllocatableMemory(node);
const nodeLabels = node.metadata?.labels;
const cells: IRow['cells'] = [
{
title: <ResourceLink kind="Node" name={getName(node)} title={getName(node)} />,
Expand All @@ -60,7 +58,7 @@ const getRows: GetRows = (
title: `${getConvertedUnits(memSpec)}`,
},
{
title: nodeLabels[ZONE_LABELS[0]] || nodeLabels[ZONE_LABELS[1]] || '-',
title: getZone(node) || '-',
},
];
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import {
getNodeAllocatableMemory,
} from '@console/shared';
import { useSelectList } from '@console/shared/src/hooks/select-list';
import { hasNoTaints } from '../../utils';
import { hasNoTaints, getZone } from '../../utils';
import { GetRows } from './types';

import './node-selection-list.scss';

const tableColumnClasses = [
Expand Down Expand Up @@ -60,7 +61,7 @@ const getRows: GetRows = (
title: roles.join(', ') ?? '-',
},
{
title: node.metadata.labels?.['failure-domain.beta.kubernetes.io/zone'] ?? '-',
title: getZone(node) || '-',
},
{
title: `${humanizeCpuCores(cpuSpec).string || '-'}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ export const diskModeDropdownItems = Object.freeze({
FILESYSTEM: 'Filesystem',
});

export const ZONE_LABELS = [
'topology.kubernetes.io/zone',
'failure-domain.beta.kubernetes.io/zone', // deprecated
];

export const DISK_TYPES: {
[key: string]: {
property: keyof typeof DiskMechanicalProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ import * as _ from 'lodash';
import { NodeKind, MatchExpression } from '@console/internal/module/k8s';
import { NodeAffinityTerm, HostNamesMap } from '../components/auto-detect-volume/types';
import { getName } from '@console/shared';
import { ZONE_LABELS } from '../constants';

export const hasNoTaints = (node: NodeKind): boolean => _.isEmpty(node.spec?.taints);

export const getZone = (node: NodeKind) =>
node.metadata.labels?.[ZONE_LABELS[0]] || node.metadata.labels?.[ZONE_LABELS[1]];

export const getNodes = (
showNodes: boolean,
allNodes: string[],
Expand Down

0 comments on commit bf732d3

Please sign in to comment.