Skip to content

Commit

Permalink
fix the return value on the route to make it work with the better fro…
Browse files Browse the repository at this point in the history
…ntend checker

Fix issue where the clusterName values were being re-used
  • Loading branch information
Nathan219 committed Jun 30, 2017
1 parent 58b9700 commit aa2f976
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion lib/models/rabbitmq/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ RabbitMQ.prototype.contextVersionDeleted = function (data) {
}

RabbitMQ.prototype.createCluster = function (data) {
this._publisher.publishTask('cluster.create', data)
return this._publisher.publishTask('cluster.create', data)
}

RabbitMQ.prototype.deleteCluster = function (data) {
Expand Down
1 change: 1 addition & 0 deletions lib/models/services/cluster-config-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ module.exports = class ClusterConfigService {
* @param {String[]} data.testReporters - array of names of the testReporters
* @param {String} data.clusterName - name of the cluster
* @param {ObjectId=} data.parentInputClusterConfigId - Id of the parent cluster
* @param {Boolean} data.shouldNotAutoFork - True if this cluster should not fork branches
*
* @return {Promise} with object that has AutoIsolationConfig
*/
Expand Down
37 changes: 20 additions & 17 deletions lib/routes/docker-compose-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function makeCreateOptsFromBody (sessionUser, body, mainInstanceServiceName) {
isTesting: isTesting || false,
testReporters: testReporters || [],
clusterName,
shouldNotAutoFork,
shouldNotAutoFork: shouldNotAutoFork || true,
parentInputClusterConfigId: parentInputClusterConfigId || ''
}
}
Expand Down Expand Up @@ -117,6 +117,23 @@ const postRoute = function (req, res, next) {
.asCallback(responseHandler.bind(null, res, next))
}

/**
* Takes the result from parsing the compose, and turns them into cluster create jobs
* @param {SessionUser} sessionUser - This user
* @param {Object} body - Cluster create options
* @param {Object} serviceNames
* @param {String[]} serviceNames.builds - Clusters created from the owning repo
* @param {String[]} serviceNames.externals - Clusters created from github links
* @param {Number} serviceNames.total - Total number of clusters to be generated
*/
function createClusters (sessionUser, body, serviceNames) {
return Promise.map(serviceNames, (service) => {
const newBody = Object.assign({name: generateHashClusterName()}, body)
return rabbitMQ.createCluster(makeCreateOptsFromBody(sessionUser, newBody, service))
.return({ service: service, hash: newBody.name })
})
}

/**
* Enqueues a Cluster Create job for each build and external main in the Compose File
*
Expand Down Expand Up @@ -150,22 +167,8 @@ const multiClusterCreate = function (sessionUser, body) {
const serviceKeys = ClusterConfigService.getUniqueServicesKeysFromOctobearResults(results)
// Now that we have the main instances, we need to create clusters for each one.
return Promise.props({
builds: Promise.map(serviceKeys.builds, (buildKey) => {
const hash = generateHashClusterName()
body.name = hash
return Promise.try(() => {
return rabbitMQ.createCluster(makeCreateOptsFromBody(sessionUser, body, buildKey))
})
.return({ service: buildKey, hash })
}),
externals: Promise.map(serviceKeys.externals, (externalKey) => {
const hash = generateHashClusterName()
body.name = hash
return Promise.try(() => {
return rabbitMQ.createCluster(makeCreateOptsFromBody(sessionUser, body, externalKey))
})
.return({ service: externalKey, hash })
})
builds: createClusters(sessionUser, body, serviceKeys.builds),
externals: createClusters(sessionUser, body, serviceKeys.externals)
})
})
.tap((results) => {
Expand Down

0 comments on commit aa2f976

Please sign in to comment.