Skip to content

Commit 8d4a595

Browse files
committed
HARMONY-2159: Add support in Harmony to handle non-retriable errors from service.
1 parent c30c396 commit 8d4a595

File tree

2 files changed

+37
-3
lines changed

2 files changed

+37
-3
lines changed

services/harmony/app/backends/workflow-orchestration/work-item-updates.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,13 @@ export async function processWorkItem(
708708

709709
// retry failed work-items up to a limit
710710
if (status === WorkItemStatus.FAILED) {
711-
if (workItem.retryCount < env.workItemRetryLimit) {
711+
if (message_category === 'noretry') {
712+
logger.warn('This error is not retriable.');
713+
logger.warn(
714+
`Updating work item for ${workItemID} to ${status} with message ${message}`,
715+
{ workFailureMessage: message, serviceId: workItem.serviceID, status },
716+
);
717+
} else if (workItem.retryCount < env.workItemRetryLimit) {
712718
logger.info(`Retrying failed work-item ${workItemID}`);
713719
workItem.retryCount += 1;
714720
workItem.status = WorkItemStatus.READY;

services/harmony/test/work-items/retries.ts

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ describe('Work item failure retries', function () {
8787
});
8888
});
8989

90-
describe('And a work-item fails the first time', async function () {
90+
describe('And a work-item fails two times', async function () {
9191
hookRangesetRequest('1.0.0', collection, 'all', { query: { ...reprojectQuery, ...{ maxResults: 1 } } });
9292
hookRedirect('joe');
9393
before(async function () {
@@ -147,7 +147,8 @@ describe('Work item failure retries', function () {
147147
});
148148
});
149149
});
150-
describe('And a work-item fails the first time', async function () {
150+
151+
describe('And a work-item fails three times', async function () {
151152
hookRangesetRequest('1.0.0', collection, 'all', { query: { ...reprojectQuery, ...{ maxResults: 1 } } });
152153
hookRedirect('joe');
153154
before(async function () {
@@ -209,5 +210,32 @@ describe('Work item failure retries', function () {
209210
});
210211
});
211212
});
213+
214+
describe('And a work-item fails with no retry error', async function () {
215+
hookRangesetRequest('1.0.0', collection, 'all', { query: { ...reprojectQuery, ...{ maxResults: 1 } } });
216+
hookRedirect('joe');
217+
before(async function () {
218+
const res = await getWorkForService(this.backend, 'harmonyservices/query-cmr:stable');
219+
const { workItem } = JSON.parse(res.text);
220+
221+
workItem.status = WorkItemStatus.FAILED;
222+
workItem.message = 'The service returns noretry error';
223+
workItem.message_category = 'noretry';
224+
workItem.results = [];
225+
226+
await updateWorkItem(this.backend, workItem);
227+
228+
this.workItem = await getWorkItemById(db, workItem.id);
229+
});
230+
231+
it('Changes the work-item status to failed immediately without retries', async function () {
232+
expect(this.workItem.status).to.equal(WorkItemStatus.FAILED);
233+
expect(this.workItem.retryCount).to.equal(0);
234+
});
235+
it('changes the work-item status to failed', async function () {
236+
const { job } = await Job.byJobID(db, this.workItem.jobID);
237+
expect(job.status).to.equal(JobStatus.FAILED);
238+
});
239+
});
212240
});
213241
});

0 commit comments

Comments
 (0)