1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 06:00:06 +02:00

fix: only get a single dg for id

This commit is contained in:
Wyatt Preul 2017-09-13 13:30:45 -05:00 committed by Sérgio Ramos
parent 1fe36f0e1b
commit e70d80425a
6 changed files with 48 additions and 33 deletions

View File

@ -66,7 +66,7 @@ frontend:
# BACKEND # BACKEND
############################################################################# #############################################################################
api: api:
image: joyent/copilot-api:1.8.6 image: joyent/copilot-api:1.8.8
mem_limit: 512m mem_limit: 512m
links: links:
- consul:consul - consul:consul

View File

@ -21,7 +21,7 @@
"joi": "^10.6.0", "joi": "^10.6.0",
"joyent-cp-gql-schema": "^1.7.0", "joyent-cp-gql-schema": "^1.7.0",
"piloted": "^3.1.1", "piloted": "^3.1.1",
"portal-api": "^1.8.6", "portal-api": "^1.8.8",
"toppsy": "^1.1.0", "toppsy": "^1.1.0",
"triton": "^5.2.0" "triton": "^5.2.0"
} }

View File

@ -119,12 +119,19 @@ const startServer = function ({ docker, rethink }) {
const handlerError = function (err) { const handlerError = function (err) {
if (err) { if (err) {
console.error(err); console.error(err);
console.error(err.stack);
process.exit(1); process.exit(1);
} }
}; };
process.on('uncaughtException', (err) => {
console.error(err);
console.error(err.stack);
});
process.on('unhandledRejection', (err) => { process.on('unhandledRejection', (err) => {
console.error(err); console.error(err);
console.error(err.stack);
}); });
loadConfig(); loadConfig();

View File

@ -460,6 +460,16 @@ class Data extends EventEmitter {
getDeploymentGroup (query, cb) { getDeploymentGroup (query, cb) {
query = query || {}; query = query || {};
if (query.id) {
return this._db.deployment_groups.get(query.id, (err, deploymentGroup) => {
if (err) {
return cb(err);
}
cb(null, Transform.fromDeploymentGroup(this._getDeploymentGroupFns(deploymentGroup)));
});
}
this._db.deployment_groups.query(query, (err, deploymentGroups) => { this._db.deployment_groups.query(query, (err, deploymentGroups) => {
if (err) { if (err) {
return cb(err); return cb(err);
@ -487,16 +497,16 @@ class Data extends EventEmitter {
VAsync.parallel({ VAsync.parallel({
funcs: [ funcs: [
(cb) => { (next) => {
if (!res.dg) { if (!res.dg) {
return cb(); return next();
} }
this._db.deployment_groups.remove({ id }, cb); this._db.deployment_groups.remove({ id }, next);
}, },
(cb) => { (next) => {
if (!res.services) { if (!res.services) {
return cb(); return next();
} }
VAsync.forEachParallel({ VAsync.forEachParallel({
@ -504,11 +514,11 @@ class Data extends EventEmitter {
func: ({ id }, next) => { func: ({ id }, next) => {
this._db.services.remove({ id }, next); this._db.services.remove({ id }, next);
} }
}); }, next);
}, },
(cb) => { (next) => {
if (!res.instances) { if (!res.instances) {
return cb(); return next();
} }
VAsync.forEachParallel({ VAsync.forEachParallel({
@ -516,67 +526,65 @@ class Data extends EventEmitter {
func: ({ id }, next) => { func: ({ id }, next) => {
this._db.instances.remove({ id }, next); this._db.instances.remove({ id }, next);
} }
}); }, next);
}, },
(cb) => { (next) => {
VAsync.forEachParallel({ VAsync.forEachParallel({
inputs: res.versions, inputs: res.versions,
func: ({ id }, next) => { func: ({ id }, next) => {
this._db.versions.remove({ id }, next); this._db.versions.remove({ id }, next);
} }
}); }, next);
}, },
(cb) => { (next) => {
VAsync.forEachParallel({ VAsync.forEachParallel({
inputs: res.manifests, inputs: res.manifests,
func: ({ id }, next) => { func: ({ id }, next) => {
this._db.manifests.remove({ id }, next); this._db.manifests.remove({ id }, next);
} }
}); }, next);
} }
] ]
}, (err) => { }, cb);
cb(err, res.cb);
});
}; };
VAsync.parallel({ VAsync.parallel({
funcs: [ funcs: [
(cb) => { (next) => {
this.getDeploymentGroup({ id }, (err, dg) => { this.getDeploymentGroup({ id }, (err, dg) => {
if (internals.isNotFound(err)) { if (internals.isNotFound(err)) {
return cb(null, {}); return next(null, {});
} }
cb(err, { dg }); next(err, { dg });
}); });
}, },
(cb) => { (next) => {
this.getServices({ deploymentGroupId: id }, (err, services) => { this.getServices({ deploymentGroupId: id }, (err, services) => {
if (internals.isNotFound(err)) { if (internals.isNotFound(err)) {
return cb(null, {}); return next(null, {});
} }
cb(err, { services }); next(err, { services });
}); });
}, },
(cb) => { (next) => {
this.getInstances({ deploymentGroupId: id }, (err, instances) => { this.getInstances({ deploymentGroupId: id }, (err, instances) => {
if (internals.isNotFound(err)) { if (internals.isNotFound(err)) {
return cb(null, {}); return next(null, {});
} }
cb(err, { instances }); next(err, { instances });
}); });
}, },
(cb) => { (next) => {
this.getVersions({ deploymentGroupId: id }, (err, versions) => { this.getVersions({ deploymentGroupId: id }, (err, versions) => {
cb(err, { versions }); next(err, { versions });
}); });
}, },
(cb) => { (next) => {
this.getManifests({ deploymentGroupId: id }, (err, manifests) => { this.getManifests({ deploymentGroupId: id }, (err, manifests) => {
cb(err, { manifests }); next(err, { manifests });
}); });
} }
] ]

View File

@ -1,6 +1,6 @@
{ {
"name": "portal-api", "name": "portal-api",
"version": "1.8.6", "version": "1.8.8",
"description": "", "description": "",
"main": "./lib/index.js", "main": "./lib/index.js",
"scripts": { "scripts": {

View File

@ -81,7 +81,7 @@ frontend:
# BACKEND # BACKEND
############################################################################# #############################################################################
api: api:
image: joyent/copilot-api:1.8.6 image: joyent/copilot-api:1.8.8
mem_limit: 1g mem_limit: 1g
expose: expose:
- 3000 - 3000