Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add error msg when status failed scheduling #306

Merged
merged 5 commits into from
Jun 5, 2023
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
16 changes: 13 additions & 3 deletions src/Routes/Tables/Jobs/GraphTab/Details.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,19 @@ const Details = ({ node, jobId, isDisabledBtnRunDebug }) => {
{
label: 'Logs',
key: 'logs-tab',
children: <NodeLogs node={node} taskDetails={taskDetails} />,
children: (
<NodeLogs
node={node}
taskDetails={taskDetails}
key={`${node.nodeName}-logs-tab-node-logs`}
/>
),
},
{
label: 'Algorithm Details',
key: 'algorithms-tab',
children: (
<OverflowContainer>
<OverflowContainer key={`${node.nodeName}-algorithms-tab-json"`}>
<JsonSwitch
obj={algorithmDetailsDataView}
jobId={jobId}
Expand All @@ -132,7 +138,11 @@ const Details = ({ node, jobId, isDisabledBtnRunDebug }) => {
label: 'Input Output Details',
key: 'io-details-tab',
children: (
<NodeInputOutput payload={node} algorithm={algorithmDetails} />
<NodeInputOutput
payload={node}
algorithm={algorithmDetails}
key={`${node.nodeName}-io-details-tab-node-input-output`}
/>
),
},
],
Expand Down
93 changes: 72 additions & 21 deletions src/Routes/Tables/Jobs/NodeLogs.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { FlexBox } from 'components/common';
import LogsViewer from 'components/common/LogsViewer';
import { useLogs } from 'hooks/graphql';
import { useDebounceCallback } from '@react-hook/debounce';
import GRAPH_TYPES from './graphUtils/types';
import OptionBox from './GraphTab/OptionBox';

const Container = styled.div`
Expand Down Expand Up @@ -57,6 +58,24 @@ const ErrorMsg = {
ERROR: 'Algorithm down',
};

const msgAlertFailedScheduling = (typeText, message) => {
const lines = message.split('\n');
const [firstLine, ...remainingLines] = lines;

return (
<div>
<p>
<strong>
{typeText} : {firstLine}
</strong>
</p>
{remainingLines.map(line => (
<div>{line}</div>
))}
</div>
);
};

const NodeLogs = ({ node, taskDetails }) => {
const { kibanaUrl } = useSelector(selectors.connection);
const [currentTask, setCurrentTask] = useState(undefined);
Expand All @@ -67,11 +86,19 @@ const NodeLogs = ({ node, taskDetails }) => {
const [errorMsgImage, setErrorMsgImage] = useState(undefined);
const [logErrorNode, setLogErrorNode] = useState([]);
const [linkKibana, setLinkKibana] = useState();
const [isStatusFailedScheduling] = useState(
node?.status === GRAPH_TYPES.STATUS.FAILED_SCHEDULING || false
);
const [
isStatusFailedSchedulingTask,
setIsStatusFailedSchedulingTask,
] = useState(false);

const oTask = useMemo(
() => taskDetails.find(t => t.taskId === currentTask) || taskDetails[0],
[currentTask, taskDetails]
);

const { taskId, podName } = oTask;

const { logs, msgPodStatus } = useLogs({
Expand All @@ -86,6 +113,9 @@ const NodeLogs = ({ node, taskDetails }) => {
useEffect(() => {
setCurrentTask(taskId);
setIsLoadLog(false);
setIsStatusFailedSchedulingTask(
oTask?.status === GRAPH_TYPES.STATUS.FAILED_SCHEDULING || false
);
}, [taskId]);

useEffect(() => {
Expand All @@ -107,9 +137,7 @@ const NodeLogs = ({ node, taskDetails }) => {
}, [msgPodStatus]);

const options = taskDetails.map((task, indexTaskItem) => (
// TODO: implement a better key
// eslint-disable-next-line
<Select.Option key={indexTaskItem} value={indexTaskItem}>
<Select.Option key={`task-${task.taskId}`} value={indexTaskItem}>
<OptionBox
index={indexTaskItem + 1}
taskId={task.taskId}
Expand Down Expand Up @@ -198,7 +226,11 @@ const NodeLogs = ({ node, taskDetails }) => {
<Typography.Text style={{ marginLeft: '10px' }}>
Source :{' '}
</Typography.Text>

<SelectStyle
disabled={
isStatusFailedSchedulingTask || isStatusFailedScheduling
}
defaultValue={logModes.ALGORITHM}
onChange={value => setLogMode(value)}>
<Select.Option
Expand All @@ -217,7 +249,7 @@ const NodeLogs = ({ node, taskDetails }) => {
</FlexBox>
</FiltersPanel>
<RadioGroupStyle>
{node.status !== 'FailedScheduling' ? (
{!(isStatusFailedSchedulingTask || isStatusFailedScheduling) ? (
<Row justify="start" align="middle">
<Col span={5}>
<Radio.Group
Expand Down Expand Up @@ -248,7 +280,24 @@ const NodeLogs = ({ node, taskDetails }) => {
)}
</Row>
) : (
<Alert message="Error" description={node.warnings} type="error" />
(node?.warnings?.length > 0 && (
<Alert
description={msgAlertFailedScheduling(
'Warning',
node.warnings[0]
)}
type="warning"
style={{ whiteSpace: 'pre-line' }}
/>
)) ||
(node?.error && (
<Alert
description={msgAlertFailedScheduling('Error', node.error)}
type="error"
style={{ whiteSpace: 'pre-line' }}
/>
)) ||
null
)}
</RadioGroupStyle>

Expand All @@ -262,21 +311,23 @@ const NodeLogs = ({ node, taskDetails }) => {
{errorMsgImage && <InfoCircleOutlined />} {errorMsgImage}{' '}
</Typography.Text>

<Container>
{isLoadLog ? (
<Spin indicator={LoadingOutlined} />
) : (
<LogsViewer
dataSource={logs.length > 0 ? logs : logErrorNode}
id={node?.nodeName ?? ''}
emptyDescription={
logMode === logModes.ALGORITHM
? 'No algorithm logs'
: 'No system logs'
}
/>
)}
</Container>
{!(isStatusFailedSchedulingTask || isStatusFailedScheduling) && (
<Container>
{isLoadLog ? (
<Spin indicator={LoadingOutlined} />
) : (
<LogsViewer
dataSource={logs.length > 0 ? logs : logErrorNode}
id={node?.nodeName ?? ''}
emptyDescription={
logMode === logModes.ALGORITHM
? 'No algorithm logs'
: 'No system logs'
}
/>
)}
</Container>
)}
</>
);
};
Expand All @@ -294,7 +345,7 @@ NodeLogs.propTypes = {
endTime: PropTypes.number,
batch: PropTypes.arrayOf(PropTypes.object),
status: PropTypes.string,
warnings: PropTypes.string,
warnings: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
};
export default React.memo(NodeLogs);
15 changes: 12 additions & 3 deletions src/Routes/Tables/Jobs/graphUtils/nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,19 @@ const statusToGroup = status =>

const setNodeGroup = node => {
const { status } = node;
return { ...node, group: statusToGroup(status) };

const groupValue =
status === STATUS.FAILED_SCHEDULING && node?.warnings?.length > 0
? NODE_GROUPS.WARNING
: statusToGroup(status);
return { ...node, group: groupValue };
};

const OverrideGroup = collection => (currentGroup, resultedGroup) =>
collection.has(resultedGroup) ? resultedGroup : currentGroup;

const splitBatchToGroups = (
{ nodeName, algorithmName, batchInfo, level = 0, batch },
{ nodeName, algorithmName, batchInfo, level = 0, batch, warnings },
isStreaming
) => {
const itemsGroups = batch.map(item => item.status).map(statusToGroup);
Expand All @@ -109,6 +114,10 @@ const splitBatchToGroups = (
group = overrideGroup(group, NODE_GROUPS.WARNING);
group = overrideGroup(group, NODE_GROUPS.ERRORS);

if (warnings?.length > 0) {
group = NODE_GROUPS.WARNING;
}

return {
nodeName,
algorithmName,
Expand Down Expand Up @@ -143,7 +152,7 @@ export const formatNode = (normalizedPipeline, pipelineKind) => node => {
id: meta.nodeName,
label: meta?.extra?.batch
? `${meta.nodeName} (${meta.extra.batch})`
: `${meta.nodeName} ${node.status === 'FailedScheduling' ? ' (!) ' : ''}`,
: `${meta.nodeName} `,
};
/** @type {NodeOptions} */
const batchStyling = isBatch
Expand Down