Skip to content

Commit aeeabfc

Browse files
committed
Merge pull request #495 from CodeNow/hotfix-dedupe
Hotfix dedupe
2 parents 3f4a5df + b4aa7bf commit aeeabfc

File tree

4 files changed

+10
-18
lines changed

4 files changed

+10
-18
lines changed

lib/models/apis/docker.js

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ Docker.prototype.createImageBuilderAndAttach = function (sessionUser, version, c
117117
var self = this;
118118
debug('create container');
119119
var builderContainerData = {
120+
name: version.build._id.toString(),
120121
Image: process.env.DOCKER_IMAGE_BUILDER_NAME + ':' + process.env.DOCKER_IMAGE_BUILDER_VERSION,
121122
Env : getEnvForImageBuilder(version, dockerTag),
122123
Binds: []
@@ -127,17 +128,7 @@ Docker.prototype.createImageBuilderAndAttach = function (sessionUser, version, c
127128
'/cache': {}
128129
};
129130
}
130-
self.createContainer(builderContainerData, function (err, container) {
131-
debug('container created - ', 'err:', err, 'container:', container);
132-
if (err) { return cb(err); }
133-
var containerId = container.Id;
134-
135-
version.update({
136-
$set: { containerId: containerId }
137-
}, error.logIfErr);
138-
139-
cb(null, container);
140-
});
131+
self.createContainer(builderContainerData, cb);
141132
}
142133
};
143134

lib/models/mongo/context-version.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,13 @@ ContextVersionSchema.methods.setBuildStarted = function (user, dockerHost, build
276276
buildProps = {};
277277
}
278278
var update = {};
279+
// FIXME: lets get rid of cv.containerId soon (now mirrors build._id)
280+
// - used for buildLogs (change to build._id)
279281
update.$set = {
280282
'build.started' : Date.now(),
281283
'build.triggeredBy.github': user.accounts.github.id,
282-
'dockerHost': dockerHost
284+
'dockerHost': dockerHost,
285+
'containerId': this.build._id
283286
};
284287
Object.keys(buildProps).forEach(function (key) {
285288
update.$set['build.'+key] = buildProps[key];
@@ -813,6 +816,8 @@ ContextVersionSchema.methods.copyBuildFromContextVersion = function (contextVers
813816
var self = this;
814817
self.build.dupeFound = true;
815818
self.containerId = contextVersion.containerId;
819+
// FIXME: lets get rid of cv.containerId soon (now mirrors build._id)
820+
// - used for buildLogs (change to build._id)
816821
self.update({
817822
$set: {
818823
'build': contextVersion.build,

lib/routes/builds.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ var checkFound = require('middlewares/check-found');
2020
var Boom = mw.Boom;
2121
var runnable = require('middlewares/apis').runnable;
2222
var error = require('error');
23-
var createCount = require('callback-count');
2423
var pluck = require('101/pluck');
2524
var noop = require('101/noop');
2625

@@ -237,11 +236,8 @@ app.post('/builds/:id/actions/build',
237236
).catch(
238237
function (err, req, res, next) {
239238
error.log(err, req);
240-
var count = createCount(2, next);
241-
req.contextVersion.updateBuildError(err,
242-
logIfErrAndNext(count.next.bind(count)));
243239
req.build.modifyErrored(req.contextVersion._id,
244-
logIfErrAndNext(count.next.bind(count)));
240+
logIfErrAndNext(next));
245241
}
246242
)
247243
),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"Filibuster": "git://github.com/Runnable/Filibuster.git#v0.1.4",
8686
"console-trace": "git://github.com/numbcoder/console-trace.git",
8787
"docker-listener": "git+ssh://[email protected]:codenow/docker-listener#v0.1.1",
88-
"docker-mock": "^0.5.5",
88+
"docker-mock": "^0.5.7",
8989
"faker": "^1.0.0",
9090
"form-data": "^0.1.4",
9191
"function-proxy": "^0.5.2",

0 commit comments

Comments
 (0)