diff --git a/src/rest-server/src/controllers/v2/job.js b/src/rest-server/src/controllers/v2/job.js index 26c07f1505..69fd3bdafb 100644 --- a/src/rest-server/src/controllers/v2/job.js +++ b/src/rest-server/src/controllers/v2/job.js @@ -302,7 +302,7 @@ const getLogs = asyncHandler(async (req, res) => { res.json(data); } catch (error) { logger.error(`Got error when retrieving log list, error: ${error}`); - throw error.code === 'NoTaskLogErr' + throw error.code === 'NoTaskLogError' ? error : createError( 'Internal Server Error', diff --git a/src/rest-server/src/models/v2/job/log.js b/src/rest-server/src/models/v2/job/log.js index b072933539..b1d2b62153 100644 --- a/src/rest-server/src/models/v2/job/log.js +++ b/src/rest-server/src/models/v2/job/log.js @@ -58,9 +58,11 @@ const getLogListFromLogManager = async ( 'NoTaskLogError', `Log of task is not found.`, ); - const taskStatus = taskDetail.data.attempts[Number(taskAttemptId)]; - if (!taskStatus) { - logger.error(`Failed to find task to retrive log`); + const taskStatus = taskDetail.data.attempts.find( + (attempt) => attempt.attemptId === Number(taskAttemptId), + ); + if (!taskStatus || !taskStatus.containerIp) { + logger.error(`Failed to find task to retrive log or task not started`); throw NoTaskLogErr; } diff --git a/src/webportal/src/app/job/job-view/fabric/job-detail/components/task-role-container-list.jsx b/src/webportal/src/app/job/job-view/fabric/job-detail/components/task-role-container-list.jsx index a67ca21881..b9dbc7ba7e 100644 --- a/src/webportal/src/app/job/job-view/fabric/job-detail/components/task-role-container-list.jsx +++ b/src/webportal/src/app/job/job-view/fabric/job-detail/components/task-role-container-list.jsx @@ -134,30 +134,25 @@ PortTooltipContent.propTypes = { ports: PropTypes.object, }; -const LogDialogContent = ({ urlLists }) => { - const lists = []; - for (const p of urlLists) { - lists.push(p); - } - if (lists.length === 0) { +const LogDialogContent = ({ urls }) => { + if (isEmpty(urls)) { return No log file generated or log files be rotated; } - const urlpairs = lists.map((lists, index) => ( - - - {lists.name} - - - )); - return urlpairs; + const urlPairs = []; + for (const [key, url] of Object.entries(urls)) { + urlPairs.push( + + + {key} + + , + ); + } + return urlPairs; }; LogDialogContent.propTypes = { - urlLists: PropTypes.array, + urlLists: PropTypes.object, }; export default class TaskRoleContainerList extends React.Component { @@ -410,10 +405,15 @@ export default class TaskRoleContainerList extends React.Component { .then(({ fullLogUrls, _ }) => { this.setState({ hideAllLogsDialog: !hideAllLogsDialog, - fullLogUrls: fullLogUrls, + fullLogUrls: this.convertObjectFormat(fullLogUrls), }); }) - .catch(() => this.setState({ hideAllLogsDialog: !hideAllLogsDialog })); + .catch(() => + this.setState({ + hideAllLogsDialog: !hideAllLogsDialog, + fullLogUrls: {}, + }), + ); } getTaskPropertyFromColumnKey(item, key) { @@ -531,13 +531,7 @@ export default class TaskRoleContainerList extends React.Component { > All Logs: - + { - const lists = []; - for (const p of urlLists) { - lists.push(p); - } - if (lists.length === 0) { +const LogDialogContent = ({ urls }) => { + if (isEmpty(urls)) { return No log file generated or log files be rotated; } - const urlpairs = lists.map((lists, index) => ( - - - {lists.name} - - - )); - return urlpairs; + const urlPairs = []; + for (const [key, url] of Object.entries(urls)) { + urlPairs.push( + + + {key} + + , + ); + } + return urlPairs; }; LogDialogContent.propTypes = { - urlLists: PropTypes.array, + urlLists: PropTypes.object, }; export default class TaskAttemptList extends React.Component { @@ -223,10 +218,15 @@ export default class TaskAttemptList extends React.Component { .then(({ fullLogUrls, _ }) => { this.setState({ hideAllLogsDialog: !hideAllLogsDialog, - fullLogUrls: fullLogUrls, + fullLogUrls: this.convertObjectFormat(fullLogUrls), }); }) - .catch(() => this.setState({ hideAllLogsDialog: !hideAllLogsDialog })); + .catch(() => + this.setState({ + hideAllLogsDialog: !hideAllLogsDialog, + fullLogUrls: {}, + }), + ); } showContainerTailLog(logListUrl, logType) { @@ -432,9 +432,7 @@ export default class TaskAttemptList extends React.Component { > All Logs: - +