Skip to content

Commit f777009

Browse files
continue execution when task failed (#97)
SAAS-5961
1 parent cc0331d commit f777009

File tree

4 files changed

+41
-4
lines changed

4 files changed

+41
-4
lines changed

jobs/TaskPullerJob/TaskPuller.job.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ class TaskPullerJob extends Base {
5858
taskUid: new Chance().guid()
5959
});
6060
const task = new Task(this.codefreshAPI, this.kubernetesAPI, logger);
61-
return task.exec(taskSpec);
61+
return task.exec(taskSpec).catch((err) => {
62+
this.logger.info(err);
63+
});
6264
};
6365
}
6466

jobs/TaskPullerJob/__tests__/TaskPuller.job.spec.js

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ describe('TaskPullerJob unit tests', () => {
4141
it('Should map all results to tasks by types and execute them', () => {
4242
CreatePodTask.mockImplementationOnce(() => {
4343
return {
44-
exec: jest.fn(() => {
44+
exec: jest.fn(async () => {
4545
return {
4646
status: 'ok'
4747
};
@@ -86,6 +86,41 @@ describe('TaskPullerJob unit tests', () => {
8686
return expect(task.exec()).resolves.toEqual([]);
8787
});
8888

89+
it('Should not fail when a task failed', () => {
90+
const tasks = [
91+
{
92+
type: 'DeletePod',
93+
},
94+
{
95+
type: 'CreatePod',
96+
}
97+
];
98+
DeletePodTask.mockImplementationOnce(() => ({
99+
exec: jest.fn(async () => Promise.reject('error'))
100+
}));
101+
CreatePodTask.mockImplementationOnce(() => ({
102+
exec: jest.fn(async () => Promise.resolve('value'))
103+
}));
104+
const logger = createLogger();
105+
const task = new TaskPullerJob({
106+
pullTasks: jest.fn().mockResolvedValue(tasks),
107+
}, _.noop(), logger);
108+
return expect(task.exec()).resolves.toEqual(['value', undefined]);
109+
});
110+
111+
it('Should not fail when task failed', () => {
112+
const tasks = [
113+
{
114+
prop: 'a'
115+
},
116+
];
117+
const logger = createLogger();
118+
const task = new TaskPullerJob({
119+
pullTasks: jest.fn().mockResolvedValue(tasks),
120+
}, _.noop(), logger);
121+
return expect(task.exec()).resolves.toEqual([]);
122+
});
123+
89124
it('Should always execute and resolve the HIGH priority task first', async () => {
90125
const tasks = [
91126
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "venona",
3-
"version": "0.30.3",
3+
"version": "0.30.4",
44
"description": "Codefresh agent to run on Codefresh's runtime environment and execute pipeline",
55
"main": "index.js",
66
"scripts": {

venonactl/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.30.3
1+
0.30.4

0 commit comments

Comments
 (0)