Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/BasicNodeViewer/BasicNodeViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import cn from 'bem-cn-lite';

import type {TSystemStateInfo} from '../../types/api/nodes';
import type {AdditionalNodesProps} from '../../types/additionalProps';
import type {PreparedNode} from '../../store/reducers/node/types';

import EntityStatus from '../EntityStatus/EntityStatus';
import {Tags} from '../Tags';
Expand All @@ -12,7 +12,7 @@ import './BasicNodeViewer.scss';
const b = cn('basic-node-viewer');

interface BasicNodeViewerProps {
node: TSystemStateInfo;
node: PreparedNode;
additionalNodesProps?: AdditionalNodesProps;
className?: string;
}
Expand Down Expand Up @@ -44,7 +44,7 @@ export const BasicNodeViewer = ({node, additionalNodesProps, className}: BasicNo
<label>{node.NodeId}</label>
</div>

{node.DataCenter && <Tags tags={[node.DataCenter]} />}
{node.DC && <Tags tags={[node.DC]} />}
{node.Roles && <Tags tags={node.Roles} tagsType="blue" />}
</>
) : (
Expand Down
7 changes: 3 additions & 4 deletions src/components/FullNodeViewer/FullNodeViewer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import cn from 'bem-cn-lite';

import type {TSystemStateInfo} from '../../types/api/nodes';

import type {PreparedNode} from '../../store/reducers/node/types';
import {LOAD_AVERAGE_TIME_INTERVALS} from '../../utils/constants';
import {calcUptime} from '../../utils/dataFormatters/dataFormatters';

Expand All @@ -14,7 +13,7 @@ import './FullNodeViewer.scss';
const b = cn('full-node-viewer');

interface FullNodeViewerProps {
node: TSystemStateInfo | undefined;
node: PreparedNode | undefined;
className?: string;
}

Expand All @@ -34,7 +33,7 @@ export const FullNodeViewer = ({node, className}: FullNodeViewerProps) => {
commonInfo.push(
{label: 'Version', value: node?.Version},
{label: 'Uptime', value: calcUptime(node?.StartTime)},
{label: 'DC', value: node?.DataCenterDescription},
{label: 'DC', value: node?.DataCenterDescription || node?.DC},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DataCenterDescription has more data, but it could be empty and short DC name should be used in this case

{label: 'Rack', value: node?.Rack},
);

Expand Down
3 changes: 1 addition & 2 deletions src/containers/Node/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ function Node(props: NodeProps) {
const dispatch = useDispatch();
const location = useLocation();

const {loading, wasLoaded, error, data} = useTypedSelector((state) => state.node);
const node = data?.SystemStateInfo?.[0];
const {loading, wasLoaded, error, data: node} = useTypedSelector((state) => state.node);

const match =
useRouteMatch<{id: string; activeTab: string}>(routes.node) ?? Object.create(null);
Expand Down
3 changes: 2 additions & 1 deletion src/containers/Nodes/getNodesColumns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import type {GetNodeRefFunc} from '../../types/additionalProps';
import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils';
import {UsageLabel} from '../../components/UsageLabel/UsageLabel';
import {CellWithPopover} from '../../components/CellWithPopover/CellWithPopover';
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants';

const NODES_COLUMNS_IDS = {
NodeId: 'NodeId',
Expand Down Expand Up @@ -69,7 +70,7 @@ const dataCenterColumn: NodesColumn = {
name: NODES_COLUMNS_IDS.DC,
header: 'DC',
align: DataTable.LEFT,
render: ({row}) => (row.DataCenter ? row.DataCenter : '—'),
render: ({row}) => row.DC || EMPTY_DATA_PLACEHOLDER,
width: 60,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {Column as VirtualTableColumn} from '../../../components/VirtualTabl
import {VISIBLE_ENTITIES} from '../../../store/reducers/storage/constants';
import {NodeHostWrapper} from '../../../components/NodeHostWrapper/NodeHostWrapper';
import {isSortableNodesProperty} from '../../../utils/nodes';
import {EMPTY_DATA_PLACEHOLDER} from '../../../utils/constants';

import {PDisk} from '../PDisk/PDisk';
import {b} from './shared';
Expand Down Expand Up @@ -47,7 +48,7 @@ const getStorageNodesColumns = (additionalNodesProps: AdditionalNodesProps | und
name: STORAGE_NODES_COLUMNS_IDS.DC,
header: 'DC',
width: 100,
render: ({row}) => row.DataCenter || '—',
render: ({row}) => row.DC || EMPTY_DATA_PLACEHOLDER,
align: DataTable.LEFT,
},
{
Expand Down
2 changes: 2 additions & 0 deletions src/store/reducers/node/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Reducer} from 'redux';
import {createRequestActionTypes, createApiRequest} from '../../utils';

import type {NodeAction, NodeState} from './types';
import {prepareNodeData} from './utils';

export const FETCH_NODE = createRequestActionTypes('node', 'FETCH_NODE');
export const FETCH_NODE_STRUCTURE = createRequestActionTypes('node', 'FETCH_NODE_STRUCTURE');
Expand Down Expand Up @@ -82,6 +83,7 @@ export const getNodeInfo = (id: string) => {
return createApiRequest({
request: window.api.getNodeInfo(id),
actions: FETCH_NODE,
dataHandler: prepareNodeData,
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/store/reducers/node/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
RawNodeStructure,
} from './types';

const selectNodeId = (state: NodeStateSlice) => state.node?.data?.SystemStateInfo?.[0].NodeId;
const selectNodeId = (state: NodeStateSlice) => state.node?.data?.NodeId;

const selectRawNodeStructure = (state: NodeStateSlice) => state.node?.nodeStructure;

Expand Down
11 changes: 8 additions & 3 deletions src/store/reducers/node/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type {IResponseError} from '../../../types/api/error';
import type {TSystemStateInfo} from '../../../types/api/nodes';
import type {TPDiskStateInfo} from '../../../types/api/pdisk';
import type {TStorageInfo} from '../../../types/api/storage';
import type {TEvSystemStateResponse} from '../../../types/api/systemState';
import type {TVDiskStateInfo} from '../../../types/api/vdisk';
import type {ApiRequestAction} from '../../utils';

Expand All @@ -24,8 +24,13 @@ export interface PreparedStructurePDisk extends TPDiskStateInfo {

export type PreparedNodeStructure = Record<string, PreparedStructurePDisk>;

export interface PreparedNode extends TSystemStateInfo {
DC?: string;
Rack?: string;
}

export interface NodeState {
data: TEvSystemStateResponse;
data: PreparedNode;
loading: boolean;
wasLoaded: boolean;
error?: IResponseError;
Expand All @@ -37,7 +42,7 @@ export interface NodeState {
}

export type NodeAction =
| ApiRequestAction<typeof FETCH_NODE, TEvSystemStateResponse, IResponseError>
| ApiRequestAction<typeof FETCH_NODE, PreparedNode, IResponseError>
| ApiRequestAction<typeof FETCH_NODE_STRUCTURE, TStorageInfo, IResponseError>
| ReturnType<typeof resetNode>;

Expand Down
16 changes: 16 additions & 0 deletions src/store/reducers/node/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type {TEvSystemStateResponse} from '../../../types/api/systemState';
import type {PreparedNode} from './types';

export const prepareNodeData = (data: TEvSystemStateResponse): PreparedNode => {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although is looks similar to other nodes preparation functions, it's different endpoint - /viewer/json/sysinfo, so there should be different handler

if (!data.SystemStateInfo?.length) {
return {};
}

const nodeData = data.SystemStateInfo[0];

return {
...nodeData,
DC: nodeData.Location?.DataCenter,
Rack: nodeData.Location?.Rack,
};
};
2 changes: 1 addition & 1 deletion src/store/reducers/nodes/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export interface NodesPreparedEntity {
NodeId: number;
Host?: string;
SystemState?: EFlag;
DataCenter?: string;
DC?: string;
Rack?: string;
Version?: string;
TenantName?: string;
Expand Down
5 changes: 5 additions & 0 deletions src/store/reducers/nodes/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const prepareComputeNode = (node: TComputeNodeInfo, tenantName?: string) => {
TenantName: node.Tenant ?? tenantName,
SystemState: node?.Overall,
Uptime: calcUptime(node?.StartTime),

DC: node.DataCenter,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have Location filed in viewer/json/compute

};
};

Expand Down Expand Up @@ -60,6 +62,9 @@ export const prepareNodesData = (data: TNodesInfo): NodesHandledResponse => {
Uptime: calcUptime(node.SystemState?.StartTime),
TenantName: node.SystemState?.Tenants?.[0],

DC: node.SystemState.Location?.DataCenter,
Rack: node.SystemState.Location?.Rack,

SharedCacheUsed: node.SystemState.SharedCacheStats?.UsedBytes,
SharedCacheLimit: sharedCacheLimit,
};
Expand Down
3 changes: 3 additions & 0 deletions src/store/reducers/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export interface PreparedStorageNode extends TSystemStateInfo {
PDisks: TPDiskStateInfo[] | undefined;
VDisks: TVDiskStateInfo[] | undefined;

DC?: string;
Rack?: string;

Missing: number;
Uptime: string;
}
Expand Down
4 changes: 2 additions & 2 deletions src/store/reducers/storage/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ const prepareStorageNodeData = (node: TNodeInfo): PreparedStorageNode => {
return {
NodeId: node.NodeId,
SystemState: systemState.SystemState,
DataCenter: systemState.DataCenter,
Rack: systemState.Rack,
DC: systemState.Location?.DataCenter,
Rack: systemState.Location?.Rack,
Host: systemState.Host,
Endpoints: systemState.Endpoints,
Uptime: calcUptime(systemState.StartTime),
Expand Down