Skip to content

Commit cdbac92

Browse files
committed
HARMONY-2325 Add no retries for out of memory OOM ExitCode 137
1 parent 122cd25 commit cdbac92

File tree

2 files changed

+28
-7
lines changed

2 files changed

+28
-7
lines changed

services/service-runner/app/service/service-runner.ts

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,23 @@ async function _getStacCatalogs(dir: string): Promise<string[]> {
135135
* @param msg - A default error message
136136
* @returns An error message for the status
137137
*/
138-
function _getErrorMessageOfStatus(status: k8s.V1Status, msg = 'Unknown error'): string {
138+
function _getErrorMessageAndCategoryOfStatus(
139+
status: k8s.V1Status,
140+
msg = 'Unknown error',
141+
): { error: string; category?: string } {
139142
const exitCode = status.details?.causes?.find(i => i.reason === 'ExitCode');
140143
let errorMsg = null;
144+
let category = null;
145+
141146
if (exitCode?.message === OOM_EXIT_CODE) {
142147
errorMsg = 'Service failed due to running out of memory';
148+
category = 'noretry';
143149
}
144-
return (errorMsg ? errorMsg : msg);
150+
151+
return {
152+
error: errorMsg ? errorMsg : msg,
153+
category: category,
154+
};
145155
}
146156

147157
/**
@@ -173,13 +183,16 @@ async function _getErrorInfo(
173183
}
174184
return { error, level };
175185
}
176-
const error = _getErrorMessageOfStatus(status);
177-
return { error, level: 'error' };
186+
const { error, category } = _getErrorMessageAndCategoryOfStatus(status);
187+
return { error, level: 'error', category };
178188
} catch (e) {
179189
workItemLogger.error(`Caught exception: ${e}`);
180190
workItemLogger.error(`Unable to parse out error from catalog location: ${catalogDir}`);
181-
const error = _getErrorMessageOfStatus(status, 'Service terminated without error message');
182-
return { error, level: 'error' };
191+
const { error, category } = _getErrorMessageAndCategoryOfStatus(
192+
status,
193+
'Service terminated without error message',
194+
);
195+
return { error, level: 'error', category };
183196
}
184197
}
185198

@@ -381,6 +394,10 @@ export async function runServiceFromPull(
381394
const errorLevel = errorEntries.level;
382395
const errorCategory = errorEntries.category;
383396

397+
workItemLogger.debug(`Vu runServiceFromPull:errorMessage2: ${errorMessage}`);
398+
workItemLogger.debug(`Vu runServiceFromPull:errorLevel2: ${errorLevel}`);
399+
workItemLogger.debug(`Vu runServiceFromPull:errorCategory2: ${errorCategory}`);
400+
workItemLogger.debug(`Vu runServiceFromPull:status.code2: ${status.code}`);
384401
if (errorCategory) {
385402
resolve({ error: errorMessage, errorLevel, errorCategory });
386403
} else if (status.code === 500) {

services/service-runner/test/service-runner.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ describe('Service Runner', function () {
7979
});
8080
describe('when the error status code is 137', async function () {
8181
it('returns "OOM error"', async function () {
82-
const errorMessage = (await _getErrorInfo(oomStatus, workItemWithoutErrorJson)).error;
82+
const errorInfo = await _getErrorInfo(oomStatus, workItemWithoutErrorJson);
83+
const errorMessage = errorInfo.error;
84+
const { level, category } = errorInfo;
8385
expect(errorMessage).equal('Service failed due to running out of memory');
86+
expect(level).equal('error');
87+
expect(category).equal('noretry');
8488
});
8589
});
8690
});

0 commit comments

Comments
 (0)