From da70839f7859a14b1d135bbc337e19dfe67cee68 Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Mon, 6 Apr 2015 20:15:26 +0200 Subject: [PATCH 1/3] Disable per-user healthchecks --- lib/cartodb/monitoring/health_check.js | 45 +------------------------- test/acceptance/health_check.js | 25 -------------- 2 files changed, 1 insertion(+), 69 deletions(-) diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index f59fbfb1..e929cf7d 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -56,50 +56,7 @@ HealthCheck.prototype.check = function(config, callback) { throw err; } }, - function getDBParams(err) { - if (err) { - throw err; - } - startTime = Date.now(); - self.metadataBackend.getAllUserDBParams(config.username, this); - }, - function loadMapnik(err, dbParams) { - if (err) { - throw err; - } - result.redis = { - ok: !err, - elapsed: Date.now() - startTime, - size: Object.keys(dbParams).length - }; - mapnikOptions.xml = xmlTemplate(mapnikXmlParams); - - startTime = Date.now(); - self.tilelive.load(mapnikOptions, this); - }, - function getTile(err, source) { - if (err) { - throw err; - } - - result.mapnik = { - ok: !err, - elapsed: Date.now() - startTime - }; - - startTime = Date.now(); - source.getTile(config.z, config.x, config.y, this); - }, - function handleTile(err, tile) { - result.tile = { - ok: !err - }; - - if (tile) { - result.tile.elapsed = Date.now() - startTime; - result.tile.size = tile.length; - } - + function handleResult(err) { callback(err, result); } ); diff --git a/test/acceptance/health_check.js b/test/acceptance/health_check.js index 890b559e..682deedd 100644 --- a/test/acceptance/health_check.js +++ b/test/acceptance/health_check.js @@ -51,31 +51,6 @@ suite('health checks', function () { ); }); - test('fails for invalid user because it is not in redis', function (done) { - resetHealthConfig(); - - global.environment.health.username = 'invalid'; - - assert.response(server, - healthCheckRequest, - { - status: 503 - }, - function (res, err) { - assert.ok(!err); - - var parsed = JSON.parse(res.body); - - assert.equal(parsed.enabled, true); - assert.equal(parsed.ok, false); - - assert.equal(parsed.result.redis.ok, false); - - done(); - } - ); - }); - test('error if disabled file exists', function(done) { var fs = require('fs'); From 21b5ed9c8ae51e1014812f91694421296d105171 Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Mon, 6 Apr 2015 20:35:22 +0200 Subject: [PATCH 2/3] Fixed healthcheck for jshint --- lib/cartodb/monitoring/health_check.js | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index e929cf7d..e74de4e1 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -11,24 +11,9 @@ function HealthCheck(metadataBackend, tilelive) { module.exports = HealthCheck; -var mapnikOptions = { - query: { - metatile: 1, - poolSize: 4, - bufferSize: 64 - }, - protocol: 'mapnik:', - slashes: true, - xml: null -}; - -var xmlTemplate = dot.template(fs.readFileSync(path.resolve(__dirname, 'map-config.xml'), 'utf-8')); - HealthCheck.prototype.check = function(config, callback) { - var self = this, - startTime, - result = { + var result = { redis: { ok: false }, @@ -39,7 +24,6 @@ HealthCheck.prototype.check = function(config, callback) { ok: false } }; - var mapnikXmlParams = config; step( function getManualDisable() { From 7934d659fb12c01b53ac7c9f1269ab659e4fda07 Mon Sep 17 00:00:00 2001 From: Luis Bosque Date: Mon, 6 Apr 2015 20:49:29 +0200 Subject: [PATCH 3/3] Removed more unused code from healthcheck --- lib/cartodb/monitoring/health_check.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/cartodb/monitoring/health_check.js b/lib/cartodb/monitoring/health_check.js index e74de4e1..1fca02b8 100644 --- a/lib/cartodb/monitoring/health_check.js +++ b/lib/cartodb/monitoring/health_check.js @@ -1,6 +1,4 @@ -var dot = require('dot'); var fs = require('fs'); -var path = require('path'); var step = require('step'); function HealthCheck(metadataBackend, tilelive) {