Skip to content

Commit 6ff80b2

Browse files
add image ignore
1 parent 8c6f273 commit 6ff80b2

3 files changed

Lines changed: 38 additions & 1 deletion

File tree

configs/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ CAYLEY="http://localhost:64210"
3131
REDIS_NAMESPACE="runnable:api:"
3232
DNS_JOB_QUEUE_INTERVAL=200
3333
DNS_JOB_QUEUE_INTERVAL_DELETE=60000
34+
IMAGE_BUILDER="runnable/image-builder"

lib/models/events/docker.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ DockerEvents.prototype.handleDie = function (data) {
120120
if (err) {
121121
return logErr(err);
122122
}
123+
if (isImageBuilder(data)) {
124+
return { skip: data };
125+
}
123126
var containerId = data.id;
124127
activeApi.isMe(function (err, meIsActiveApi) {
125128
if (err) { return logErr(err); }
@@ -164,6 +167,10 @@ DockerEvents.prototype.handleDie = function (data) {
164167
}
165168
};
166169

170+
function isImageBuilder (data) {
171+
return ~data.from.indexOf(process.env.IMAGE_BUILDER);
172+
}
173+
167174
function validateDieEventData (data) {
168175
if (!data.uuid) {
169176
return Boom.badRequest('Invalid data: uuid is missing');
@@ -177,6 +184,10 @@ function validateDieEventData (data) {
177184
if (!data.host) {
178185
return Boom.badRequest('Invalid data: host is missing');
179186
}
187+
if (!data.from) {
188+
console.log('missing');
189+
return Boom.badRequest('Invalid data: from is missing');
190+
}
180191
}
181192

182193
// Singleton

unit/docker-events.js

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,30 @@ describe('Docker Events', function () {
6969
dockerEvents.handleDie({uuid: 'some-uuid', id: 'some-id', time: new Date().getTime() });
7070
});
7171

72+
it('should fail if event data has no from', function (done) {
73+
error.log = function (err) {
74+
expect(err.output.payload.message).to.equal('Invalid data: from is missing');
75+
done();
76+
};
77+
dockerEvents.handleDie({
78+
uuid: 'some-uuid',
79+
id: 'some-id',
80+
time: new Date().getTime(),
81+
host: 'http://localhost:4243'
82+
});
83+
});
84+
85+
it('should return if image builder image', function (done) {
86+
var out = dockerEvents.handleDie({
87+
uuid: 'some-uuid',
88+
id: 'some-id',
89+
time: new Date().getTime(),
90+
host: 'http://localhost:4243',
91+
from: process.env.IMAGE_BUILDER
92+
});
93+
expect(out).to.have.property('skip');
94+
done();
95+
});
7296
});
7397

7498

@@ -129,7 +153,8 @@ describe('Docker Events', function () {
129153
uuid: uuid(),
130154
id: 'some-id',
131155
time: new Date().getTime(),
132-
host: 'http://localhost:4243'
156+
host: 'http://localhost:4243',
157+
from: 'container/name'
133158
};
134159
dockerEvents.handleDie(payload);
135160
dockerEvents.handleDie(payload);

0 commit comments

Comments
 (0)