mirror of
https://github.com/wassname/ray.git
synced 2026-07-29 11:26:04 +08:00
[Bugfix][Dashboard] Fix undefined logCount, errorCount UI crash (#13113)
This commit is contained in:
@@ -65,8 +65,8 @@ type ProcessStats = {
|
||||
export type Worker = {
|
||||
pid: number;
|
||||
workerId: string;
|
||||
logCount: number;
|
||||
errorCount: number;
|
||||
logCount?: number;
|
||||
errorCount?: number;
|
||||
language: string;
|
||||
jobId: string;
|
||||
coreWorkerStats: CoreWorkerStats[];
|
||||
@@ -167,8 +167,8 @@ type BaseNodeInfo = {
|
||||
};
|
||||
loadAvg: [[number, number, number], [number, number, number]];
|
||||
net: [number, number]; // Sent and received network traffic in bytes / second
|
||||
logCount: number;
|
||||
errorCount: number;
|
||||
logCount?: number;
|
||||
errorCount?: number;
|
||||
};
|
||||
|
||||
export type NodeInfoResponse = {
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "./types";
|
||||
|
||||
const ClusterErrors: ClusterFeatureRenderFn = ({ nodes }) => {
|
||||
const totalErrCount = sum(nodes.map((node) => node.errorCount));
|
||||
const totalErrCount = sum(nodes.map((node) => node.errorCount ?? 0));
|
||||
return totalErrCount === 0 ? (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
No errors
|
||||
@@ -29,26 +29,27 @@ const ClusterErrors: ClusterFeatureRenderFn = ({ nodes }) => {
|
||||
const makeNodeErrors = (
|
||||
setErrorDialog: (nodeIp: string, pid: number | null) => void,
|
||||
): NodeFeatureRenderFn => ({ node }) => {
|
||||
return node.errorCount === 0 ? (
|
||||
const errorCount = node.errorCount ?? 0;
|
||||
return errorCount === 0 ? (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
No errors
|
||||
</Typography>
|
||||
) : (
|
||||
<SpanButton onClick={() => setErrorDialog(node.ip, null)}>
|
||||
View all errors ({node.errorCount.toLocaleString()})
|
||||
View all errors ({errorCount.toLocaleString()})
|
||||
</SpanButton>
|
||||
);
|
||||
};
|
||||
|
||||
const nodeErrorsAccessor: Accessor<NodeFeatureData> = ({ node }) =>
|
||||
node.errorCount;
|
||||
node.errorCount ?? 0;
|
||||
|
||||
const makeWorkerErrors = (
|
||||
setErrorDialog: (nodeIp: string, pid: number | null) => void,
|
||||
): WorkerFeatureRenderFn => ({ node, worker }) => {
|
||||
return worker.errorCount !== 0 ? (
|
||||
<SpanButton onClick={() => setErrorDialog(node.ip, worker.pid)}>
|
||||
View errors ({worker.errorCount.toLocaleString()})
|
||||
View errors ({worker.errorCount?.toLocaleString()})
|
||||
</SpanButton>
|
||||
) : (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
@@ -58,7 +59,7 @@ const makeWorkerErrors = (
|
||||
};
|
||||
|
||||
const workerErrorsAccessor: Accessor<WorkerFeatureData> = ({ worker }) =>
|
||||
worker.errorCount;
|
||||
worker.errorCount ?? 0;
|
||||
|
||||
const makeErrorsFeature = (
|
||||
setErrorDialog: (nodeIp: string, pid: number | null) => void,
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "./types";
|
||||
|
||||
const ClusterLogs: ClusterFeatureRenderFn = ({ nodes }) => {
|
||||
const totalLogCount = sum(nodes.map((n) => n.logCount));
|
||||
const totalLogCount = sum(nodes.map((n) => n.logCount ?? 0));
|
||||
return totalLogCount === 0 ? (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
No logs
|
||||
@@ -27,27 +27,30 @@ const ClusterLogs: ClusterFeatureRenderFn = ({ nodes }) => {
|
||||
|
||||
const makeNodeLogs = (
|
||||
setLogDialog: (nodeIp: string, pid: number | null) => void,
|
||||
): NodeFeatureRenderFn => ({ node }) =>
|
||||
node.logCount === 0 ? (
|
||||
): NodeFeatureRenderFn => ({ node }) => {
|
||||
const logCount = node.logCount ?? 0;
|
||||
return logCount === 0 ? (
|
||||
<Typography color="textSecondary" component="span" variant="inherit">
|
||||
No logs
|
||||
</Typography>
|
||||
) : (
|
||||
<SpanButton onClick={() => setLogDialog(node.ip, null)}>
|
||||
View all logs ({node.logCount.toLocaleString()}{" "}
|
||||
View all logs ({logCount.toLocaleString()}{" "}
|
||||
{node.logCount === 1 ? "line" : "lines"})
|
||||
</SpanButton>
|
||||
);
|
||||
};
|
||||
|
||||
const nodeLogsAccessor: Accessor<NodeFeatureData> = ({ node }) =>
|
||||
node.logCount ? sum(Object.values(node.logCount)) : 0;
|
||||
|
||||
const makeWorkerLogs = (
|
||||
setLogDialog: (nodeIp: string, pid: number | null) => void,
|
||||
): WorkerFeatureRenderFn => ({ worker, node }) =>
|
||||
worker.logCount !== 0 ? (
|
||||
): WorkerFeatureRenderFn => ({ worker, node }) => {
|
||||
const logCount = worker.logCount ?? 0;
|
||||
return logCount !== 0 ? (
|
||||
<SpanButton onClick={() => setLogDialog(node.ip, worker.pid)}>
|
||||
View log ({worker.logCount.toLocaleString()}{" "}
|
||||
View log ({logCount.toLocaleString()}{" "}
|
||||
{worker.logCount === 1 ? "line" : "lines"})
|
||||
</SpanButton>
|
||||
) : (
|
||||
@@ -55,9 +58,10 @@ const makeWorkerLogs = (
|
||||
No logs
|
||||
</Typography>
|
||||
);
|
||||
};
|
||||
|
||||
const workerLogsAccessor: Accessor<WorkerFeatureData> = ({ worker }) =>
|
||||
worker.logCount;
|
||||
worker.logCount ?? 0;
|
||||
|
||||
const makeLogsFeature = (
|
||||
setLogDialog: (nodeIp: string, pid: number | null) => void,
|
||||
|
||||
Reference in New Issue
Block a user