Skip to content

Commit

Permalink
use reservedMemory for allocation (#1196)
Browse files Browse the repository at this point in the history
  • Loading branch information
yehiyam authored Mar 18, 2021
1 parent 6b303d3 commit 9241f84
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/task-executor/lib/helpers/etcd.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ class Etcd {
if (a.mem) {
a.mem = parse.getMemoryInMi(a.mem);
}
if (a.reservedMemory) {
a.mem += parse.getMemoryInMi(a.reservedMemory);
}

return a;
});
return arrayToMap(templates);
Expand Down
7 changes: 7 additions & 0 deletions core/task-executor/tests/stub/discoveryStub.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ const templateStoreStub = [
name: 'algo2',
workerImage: 'worker2:latest',
algorithmImage: 'algo2:v1.2'
},
{
name: 'algo3',
workerImage: 'worker3:latest',
algorithmImage: 'algo3:v1.2',
mem: '256Mi',
reservedMemory: '20Mi'
}
];

Expand Down
7 changes: 7 additions & 0 deletions core/task-executor/tests/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ describe('bootstrap', () => {
const alg2 = templateStoreStub.find(t => t.name === algo);
expect(alg1).to.deep.eql(alg2);
});
it('should get template store with reserved memory', async () => {
const algo = 'algo3';
await etcd._db.algorithms.createMany(templateStoreStub);
const templates = await etcd.getAlgorithmTemplate();
const alg1 = templates[algo];
expect(alg1.mem).to.eql(276);
});
});

0 comments on commit 9241f84

Please sign in to comment.