Skip to content
This repository has been archived by the owner on Jun 6, 2024. It is now read-only.

Add task debug info in job detail page [webportal] #4670

Merged
merged 6 commits into from
Jul 7, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from '@uifabric/styling';
import c from 'classnames';
import { capitalize, isEmpty, isNil, flatten } from 'lodash';
import { DateTime } from 'luxon';
import {
CommandBarButton,
PrimaryButton,
Expand All @@ -41,14 +42,15 @@ import {
} from 'office-ui-fabric-react/lib/DetailsList';
import PropTypes from 'prop-types';
import React from 'react';
import yaml from 'js-yaml';

import localCss from './task-role-container-list.scss';
import t from '../../../../../components/tachyons.scss';

import Context from './context';
import Timer from './timer';
import { getContainerLog } from '../conn';
import { parseGpuAttr } from '../util';
import { parseGpuAttr, printDateTime } from '../util';
import config from '../../../../../config/webportal.config';
import MonacoPanel from '../../../../../components/monaco-panel';
import StatusBadge from '../../../../../components/status-badge';
Expand Down Expand Up @@ -321,25 +323,115 @@ export default class TaskRoleContainerList extends React.Component {
}
}

getColumns() {
const columns = [
getColumns(showDebugInfo) {
const optionalColumns = [
{
key: 'number',
name: 'No.',
key: 'nodeName',
name: 'Node Name',
headerClassName: FontClassNames.medium,
minWidth: 50,
maxWidth: 50,
minWidth: 100,
maxWidth: 100,
isResizable: true,
onRender: (item, idx) => {
onRender: item => {
return (
!isNil(idx) && (
<div className={FontClassNames.mediumPlus}>{idx}</div>
)
<div className={c(FontClassNames.mediumPlus)}>
{item.podNodeName}
</div>
);
},
},
{
key: 'exitCode',
name: 'Exit Code',
headerClassName: FontClassNames.medium,
debuggy marked this conversation as resolved.
Show resolved Hide resolved
minWidth: 100,
maxWidth: 100,
isResizable: true,
onRender: item => {
return (
<div className={c(FontClassNames.mediumPlus)}>
{item.containerExitCode}
</div>
);
},
},
{
key: 'exitType',
name: 'Exit Type',
headerClassName: FontClassNames.medium,
minWidth: 100,
maxWidth: 100,
isResizable: true,
onRender: item => {
return (
<div className={c(FontClassNames.mediumPlus)}>
{item.containerExitSpec.type}
</div>
);
},
},
{
key: 'exitDiagonostic',
name: 'Exit Diagnostics',
headerClassName: FontClassNames.medium,
minWidth: 200,
maxWidth: 200,
isResizable: true,
onRender: item => {
return (
<CommandBarButton
className={FontClassNames.mediumPlus}
styles={{
root: { backgroundColor: 'transparent' },
rootDisabled: { backgroundColor: 'transparent' },
}}
text='Show Exit Diagnostics'
onClick={() => {
const result = [];
// exit spec
const spec = item.containerExitSpec;
if (spec) {
// divider
result.push(Array.from({ length: 80 }, () => '-').join(''));
result.push('');
// content
result.push('[Exit Spec]');
result.push('');
result.push(yaml.safeDump(spec));
result.push('');
}

// diagnostics
const diag = item.containerExitDiagnostics;
if (diag) {
// divider
result.push(Array.from({ length: 80 }, () => '-').join(''));
result.push('');
// content
result.push('[Exit Diagnostics]');
result.push('');
result.push(diag);
result.push('');
}

this.setState({
monacoProps: {
language: 'text',
value: result.join('\n'),
options: {
wordWrap: 'off',
readOnly: true,
},
},
monacoTitle: `Task Exit Diagonostics`,
});
}}
/>
);
},
},
{
key: 'name',
key: 'containerId',
name: 'Container ID',
headerClassName: FontClassNames.medium,
minWidth: 100,
Expand All @@ -356,6 +448,51 @@ export default class TaskRoleContainerList extends React.Component {
);
},
},
{
key: 'startTime',
name: 'Start Time',
headerClassName: FontClassNames.medium,
minWidth: 150,
isResizable: true,
onRender: item => {
return (
<div className={c(FontClassNames.mediumPlus)}>
{printDateTime(DateTime.fromISO(item.startTime))}
</div>
);
},
},
{
key: 'completionTime',
name: 'Completion Time',
headerClassName: FontClassNames.medium,
minWidth: 150,
isResizable: true,
onRender: item => {
return (
<div className={c(FontClassNames.mediumPlus)}>
{printDateTime(DateTime.fromISO(item.completionTime))}
</div>
);
},
},
];
const defaultColumns = [
{
key: 'number',
name: 'No.',
headerClassName: FontClassNames.medium,
minWidth: 50,
maxWidth: 50,
isResizable: true,
onRender: (item, idx) => {
return (
!isNil(idx) && (
<div className={FontClassNames.mediumPlus}>{idx}</div>
)
);
},
},
{
key: 'ip',
name: 'IP',
Expand Down Expand Up @@ -392,7 +529,7 @@ export default class TaskRoleContainerList extends React.Component {
className: FontClassNames.mediumPlus,
headerClassName: FontClassNames.medium,
minWidth: 120,
maxWidth: 180,
maxWidth: 200,
isResizable: true,
onRender: item => {
const ports = item.containerPorts;
Expand Down Expand Up @@ -490,6 +627,21 @@ export default class TaskRoleContainerList extends React.Component {
isResizable: true,
onRender: item => <StatusBadge status={capitalize(item.taskState)} />,
},
{
key: 'retryCount',
name: 'Retry Count',
headerClassName: FontClassNames.medium,
minWidth: 100,
maxWidth: 100,
isResizable: true,
debuggy marked this conversation as resolved.
Show resolved Hide resolved
onRender: (item, idx) => {
return (
<div className={FontClassNames.mediumPlus}>
{item.totalRetriedCount}
</div>
);
},
},
{
key: 'info',
name: 'Info',
Expand Down Expand Up @@ -595,6 +747,11 @@ export default class TaskRoleContainerList extends React.Component {
},
];

let columns = defaultColumns;
if (showDebugInfo) {
columns = defaultColumns.concat(optionalColumns);
}

return columns;
}

Expand All @@ -613,7 +770,7 @@ export default class TaskRoleContainerList extends React.Component {

render() {
const { monacoTitle, monacoProps, monacoFooterButton, logUrl } = this.state;
const { className, style, taskInfo } = this.props;
const { className, style, taskInfo, showDebugInfo } = this.props;
const status = taskInfo.taskStatuses;
return (
<div
Expand All @@ -622,7 +779,8 @@ export default class TaskRoleContainerList extends React.Component {
>
<ThemeProvider theme={theme}>
<DetailsList
columns={this.getColumns()}
styles={{ root: { overflow: 'auto' } }}
columns={this.getColumns(showDebugInfo)}
disableSelectionZone
items={status}
layoutMode={DetailsListLayoutMode.justified}
Expand Down Expand Up @@ -654,4 +812,5 @@ TaskRoleContainerList.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
taskInfo: PropTypes.object,
showDebugInfo: PropTypes.bool,
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,13 @@
import { FontClassNames, ColorClassNames, getTheme } from '@uifabric/styling';
import c from 'classnames';
import { capitalize } from 'lodash';
import { Icon, IconButton, TooltipHost } from 'office-ui-fabric-react';
import {
Icon,
IconButton,
TooltipHost,
Toggle,
Stack,
} from 'office-ui-fabric-react';
import PropTypes from 'prop-types';
import React from 'react';
import yaml from 'js-yaml';
Expand Down Expand Up @@ -101,6 +107,7 @@ export default class TaskRole extends React.Component {
super(props);
this.state = {
containerListExpanded: true,
showDebugInfo: false,
};
this.taskConfigButtonRef = React.createRef();
this.expandContainerList = this.expandContainerList.bind(this);
Expand Down Expand Up @@ -170,7 +177,16 @@ export default class TaskRole extends React.Component {
</div>
</div>
{/* right */}
<div>
<Stack horizontal verticalAlign='end' gap='s1'>
<Toggle
onText='Debug Info'
offText='Debug Info'
onChange={(event, checked) => {
this.setState({
showDebugInfo: checked,
});
}}
/>
{containerListExpanded ? (
<IconButton
iconProps={{ iconName: 'ChevronUp' }}
Expand All @@ -182,10 +198,14 @@ export default class TaskRole extends React.Component {
onClick={this.expandContainerList}
/>
)}
</div>
</Stack>
</div>
{containerListExpanded && (
<TaskRoleContainerList className={t.ph5} taskInfo={taskInfo} />
<TaskRoleContainerList
className={t.ph5}
taskInfo={taskInfo}
showDebugInfo={this.state.showDebugInfo}
/>
)}
</Card>
</div>
Expand Down