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

Fix exitDiagnostic bug when containers is null #4867

Merged
merged 1 commit into from
Sep 3, 2020
Merged
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
50 changes: 26 additions & 24 deletions src/rest-server/src/utils/frameworkConverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,33 @@ const extractRuntimeOutput = (podCompletionStatus) => {
}

let res = null;
for (const container of podCompletionStatus.containers) {
if (container.code <= 0) {
continue;
}
const message = container.message;
if (message == null) {
continue;
}
const anchor1 = /\[PAI_RUNTIME_ERROR_START\]/;
const anchor2 = /\[PAI_RUNTIME_ERROR_END\]/;
const match1 = message.match(anchor1);
const match2 = message.match(anchor2);
if (match1 !== null && match2 !== null) {
const start = match1.index + match1[0].length;
const end = match2.index;
const output = message.substring(start, end).trim();
try {
res = {
...yaml.safeLoad(output),
name: container.name,
};
} catch (error) {
logger.warn('failed to format runtime output:', output, error);
if (!_.isEmpty(podCompletionStatus.containers)) {
for (const container of podCompletionStatus.containers) {
if (container.code <= 0) {
continue;
}
const message = container.message;
if (message == null) {
continue;
}
const anchor1 = /\[PAI_RUNTIME_ERROR_START\]/;
const anchor2 = /\[PAI_RUNTIME_ERROR_END\]/;
const match1 = message.match(anchor1);
const match2 = message.match(anchor2);
if (match1 !== null && match2 !== null) {
const start = match1.index + match1[0].length;
const end = match2.index;
const output = message.substring(start, end).trim();
try {
res = {
...yaml.safeLoad(output),
name: container.name,
};
} catch (error) {
logger.warn('failed to format runtime output:', output, error);
}
break;
}
break;
}
}
return res;
Expand Down