Compare commits

..

18 Commits

Author SHA1 Message Date
Sandro Santilli
6f8f3d2057 Release 1.10.2 2014-04-08 09:57:49 +02:00
Sandro Santilli
7e1aba3368 Use signer's map_key when contacting sql-api
Includes testcase.
Fixes #188
2014-04-08 09:44:00 +02:00
Sandro Santilli
8aeadd1960 Fix show_style tool broken since 1.8.1 2014-03-31 12:55:30 +02:00
Sandro Santilli
a5b091eec8 Prepare for 1.10.2 2014-03-31 12:55:04 +02:00
Sandro Santilli
1bf7bf66b3 Release 1.10.1 2014-03-21 15:16:19 +01:00
Sandro Santilli
9e495b42ee Do not cache non-success jsonp responses
Closes #186
Includes testcase
2014-03-21 13:58:20 +01:00
Sandro Santilli
898f717254 Prepare for 1.10.1 2014-03-20 17:10:39 +01:00
Sandro Santilli
800ef32959 Release 1.10.0 2014-03-20 17:08:35 +01:00
Sandro Santilli
609d69c4c9 Upgrade of windshaft fixed connection details to client
Closes #183.
2014-03-20 10:21:28 +01:00
Sandro Santilli
9e1be39774 Switch to 3-clause BSD license
Closes #184
2014-03-20 10:20:51 +01:00
Sandro Santilli
87ac44a1f1 Upgrade windshaft to 0.20.0
Reduces noise on the "error" channel (now optionally writing to rollbar)
and avoids caching bogus mapnik renderers.
Details: http://github.com/CartoDB/Windshaft/blob/0.20.0/NEWS
2014-03-20 10:18:33 +01:00
Sandro Santilli
9c4feac19b Ensure make check fails if database preparation fails 2014-03-19 17:04:06 +01:00
Sandro Santilli
471edabe4d Reword uncaught exception error, and log full stack 2014-03-13 11:58:29 +01:00
Sandro Santilli
86841f80ca Use version of node-mapnik with temptative fix for glibc detected corruptions 2014-03-13 10:26:11 +01:00
Sandro Santilli
79348178a7 Upgrade node-varnish to 0.3.0 2014-03-12 18:11:19 +01:00
Sandro Santilli
60b552027b Add optional support for rollbar
Re-targets to 1.10.0
Also installs an uncaught exception handler

Closes #150
2014-03-12 17:21:35 +01:00
Sandro Santilli
62cbb15089 Include tiler version in startup log 2014-03-11 12:21:00 +01:00
Sandro Santilli
667b911023 Prepare for 1.9.1 2014-03-10 17:41:44 +01:00
15 changed files with 304 additions and 59 deletions

27
LICENCE
View File

@@ -1,27 +0,0 @@
Copyright (c) 2011, Vizzuality
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software
must display the following acknowledgement:
This product includes software developed by Vizzuality.
4. Neither the name of Vizzuality nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS "AS IS" AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

27
LICENSE Normal file
View File

@@ -0,0 +1,27 @@
Copyright (c) 2014, Vizzuality
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

37
NEWS.md
View File

@@ -1,3 +1,40 @@
1.10.2 -- 2014-04-08
--------------------
Bug fixes:
- Fix show_style tool broken since 1.8.1
- Fix X-Cache-Channel of tiles accessed via signed token (#188)
1.10.1 -- 2014-03-21
--------------------
Bug fixes:
- Do not cache non-success jsonp responses (#186)
1.10.0 -- 2014-03-20
-------------------
New features:
- Add optional support for rollbar (#150)
Enhancements:
- Do not send connection details to client (#183)
- Upgrade node-varnish to 0.3.0
- Upgrade Windshaft to 0.20.0, see
http://github.com/CartoDB/Windshaft/blob/0.20.0/NEWS
- Include tiler version in startup log
- Install an uncaught exception handler
- Require own fork of node-mapnik, with temptative fix
for libxml usage (glibc detected corruptions)
Other changes:
- Switch to 3-clause BSD license (#184)
1.9.0 -- 2014-03-10
-------------------

20
app.js
View File

@@ -30,13 +30,22 @@ global.environment = require(__dirname + '/config/environments/' + ENV);
_.extend(global.settings, global.environment);
global.log4js = require('log4js')
log4js.configure({
log4js_config = {
appenders: [
{ type: "console", layout: { type:'basic' } }
],
replaceConsole:true
});
};
if ( global.environment.rollbar ) {
log4js_config.appenders.push({
type: __dirname + "/lib/cartodb/log4js_rollbar.js",
options: global.environment.rollbar
});
}
log4js.configure(log4js_config);
global.logger = log4js.getLogger();
// Include cartodb_windshaft only _after_ the "global" variable is set
// See https://github.com/Vizzuality/Windshaft-cartodb/issues/28
@@ -53,8 +62,10 @@ ws.maxConnections = global.environment.maxConnections || 128;
ws.listen(global.environment.port, global.environment.host);
var version = require("./package").version;
ws.on('listening', function() {
console.log("Windshaft tileserver started on "
console.log("Windshaft tileserver " + version + " started on "
+ global.environment.host + ':' + global.environment.port
+ " (" + ENV + ")");
});
@@ -69,3 +80,6 @@ process.on('SIGUSR2', function() {
ws.dumpCacheStats();
});
process.on('uncaughtException', function(err) {
logger.error('Uncaught exception: ' + err.stack);
});

View File

@@ -122,6 +122,15 @@ var config = {
https: 'cartocdn.global.ssl.fastly.net'
}
}
// Optional rollbar support
,rollbar: {
token: 'secret',
// See http://github.com/rollbar/node_rollbar#configuration-reference
options: {
endpoint: 'https://api.rollbar.com/api/1/',
handler: 'inline'
}
}
};
module.exports = config;

View File

@@ -122,6 +122,15 @@ var config = {
https: 'cartocdn.global.ssl.fastly.net'
}
}
// Optional rollbar support
,rollbar: {
token: 'secret',
// See http://github.com/rollbar/node_rollbar#configuration-reference
options: {
endpoint: 'https://api.rollbar.com/api/1/',
handler: 'inline'
}
}
};
module.exports = config;

View File

@@ -76,9 +76,14 @@ var CartodbWindshaft = function(serverOptions) {
var that = this;
var thatArgs = arguments;
var statusCode;
if ( args.length > 2 ) statusCode = args[2];
else {
statusCode = args[1] || 200;
if ( res._windshaftStatusCode ) {
// Added by our override of sendError
statusCode = res._windshaftStatusCode;
} else {
if ( args.length > 2 ) statusCode = args[2];
else {
statusCode = args[1] || 200;
}
}
var req = res.req;
Step (
@@ -117,6 +122,14 @@ var CartodbWindshaft = function(serverOptions) {
);
};
var ws_sendError = ws.sendError;
ws.sendError = function() {
var res = arguments[0];
var statusCode = arguments[2];
res._windshaftStatusCode = statusCode;
ws_sendError.apply(this, arguments);
};
/**
* Helper to allow access to the layer to be used in the maps infowindow popup.
*/

View File

@@ -0,0 +1,49 @@
var rollbar = require("rollbar");
/**
* Rollbar Appender. Sends logging events to Rollbar using node-rollbar
*
* @param config object with rollbar configuration data
* {
* token: 'your-secret-token',
* options: node-rollbar options
* }
*/
function rollbarAppender(config) {
var opt = config.options;
rollbar.init(opt.token, opt.options);
return function(loggingEvent) {
/*
For logger.trace('one','two','three'):
{ startTime: Wed Mar 12 2014 16:27:40 GMT+0100 (CET),
categoryName: '[default]',
data: [ 'one', 'two', 'three' ],
level: { level: 5000, levelStr: 'TRACE' },
logger: { category: '[default]', _events: { log: [Object] } } }
*/
// Levels:
// TRACE 5000
// DEBUG 10000
// INFO 20000
// WARN 30000
// ERROR 40000
// FATAL 50000
//
// We only log error and higher errors
//
if ( loggingEvent.level.level < 40000 ) return;
rollbar.reportMessage(loggingEvent.data);
};
}
function configure(config) {
return rollbarAppender(config);
}
exports.name = "rollbar";
exports.appender = rollbarAppender;
exports.configure = configure;

View File

@@ -285,8 +285,31 @@ module.exports = function(){
}
return [req.params.table];
}
var username = that.userByReq(req);
me.affectedTables(username, req.params.map_key, sql, this);
var user, key;
var next = this;
Step (
function findUserKey() {
if ( req.params.hasOwnProperty('_authorizedBySigner') ) {
user = req.params._authorizedBySigner;
cartoData.getUserMapKey(user, this);
} else {
user = that.userByReq(req);
key = req.params.map_key || req.params.api_key;
return null;
}
},
function getAffected(err, data) {
if ( err ) throw err;
if ( data ) {
if ( req.profiler ) req.profiler.done('getSignerMapKey');
key = data;
}
me.affectedTables(user, key, sql, this); // in addCacheChannel
},
function finish(err, data) {
next(err,data);
}
);
},
function buildCacheChannel(err, tableNames) {
if ( err ) throw err;
@@ -407,7 +430,7 @@ module.exports = function(){
Step(
function getTables() {
me.affectedTables(usr, key, sql, this);
me.affectedTables(usr, key, sql, this); // in afterLayergroupCreate
},
function getLastupdated(err, tableNames) {
if (req.profiler) req.profiler.done('affectedTables');
@@ -671,6 +694,7 @@ module.exports = function(){
}
// Authorized by "signed_by" !
_.extend(req.params, { _authorizedBySigner: signed_by });
that.setDBAuth(signed_by, req.params, function(err) {
if (req.profiler) req.profiler.done('setDBAuth');
callback(err, true); // authorized (or error)

72
npm-shrinkwrap.json generated
View File

@@ -1,21 +1,49 @@
{
"name": "windshaft-cartodb",
"version": "1.9.0",
"version": "1.10.2",
"dependencies": {
"node-varnish": {
"version": "0.2.0",
"from": "http://github.com/Vizzuality/node-varnish/tarball/v0.2.0"
"version": "0.3.0",
"from": "http://github.com/Vizzuality/node-varnish/tarball/0.3.0"
},
"underscore": {
"version": "1.3.3"
},
"windshaft": {
"version": "0.19.4",
"from": "http://github.com/CartoDB/Windshaft/tarball/0.19.4",
"version": "0.20.0",
"from": "http://github.com/CartoDB/Windshaft/tarball/0.20.0",
"dependencies": {
"grainstore": {
"version": "0.18.1",
"dependencies": {
"carto": {
"version": "0.9.5-cdb2",
"from": "http://github.com/CartoDB/carto/tarball/0.9.5-cdb2",
"dependencies": {
"underscore": {
"version": "1.4.4"
},
"xml2js": {
"version": "0.2.8",
"dependencies": {
"sax": {
"version": "0.5.8"
}
}
},
"optimist": {
"version": "0.6.1",
"dependencies": {
"wordwrap": {
"version": "0.0.2"
},
"minimist": {
"version": "0.0.8"
}
}
}
}
},
"mapnik-reference": {
"version": "5.0.7"
},
@@ -102,7 +130,7 @@
}
},
"srs": {
"version": "0.3.10"
"version": "0.3.11"
},
"zipfile": {
"version": "0.4.3"
@@ -145,7 +173,7 @@
"version": "0.1.25",
"dependencies": {
"graceful-fs": {
"version": "2.0.2"
"version": "2.0.3"
}
}
}
@@ -167,7 +195,7 @@
"version": "0.1.25",
"dependencies": {
"graceful-fs": {
"version": "2.0.2"
"version": "2.0.3"
},
"inherits": {
"version": "2.0.1"
@@ -303,7 +331,7 @@
}
},
"tilelive-mapnik": {
"version": "0.6.7",
"version": "0.6.8",
"dependencies": {
"eio": {
"version": "0.2.2"
@@ -320,8 +348,8 @@
"version": "2.3.1"
},
"carto": {
"version": "0.9.5-cdb2",
"from": "http://github.com/CartoDB/carto/tarball/0.9.5-cdb2",
"version": "0.9.5-cdb3",
"from": "http://github.com/CartoDB/carto/tarball/0.9.5-cdb3",
"dependencies": {
"underscore": {
"version": "1.4.4"
@@ -350,6 +378,10 @@
}
}
},
"step-profiler": {
"version": "0.0.1",
"from": "git://github.com/CartoDB/node-step-profiler.git#0.0.1"
},
"underscore.string": {
"version": "1.1.6",
"dependencies": {
@@ -404,7 +436,8 @@
}
},
"mapnik": {
"version": "0.7.26"
"version": "0.7.26-cdb1",
"from": "http://github.com/Vizzuality/node-mapnik/tarball/0.7.26-cdb1"
},
"lzma": {
"version": "1.2.3"
@@ -425,8 +458,16 @@
}
}
},
"strftime": {
"version": "0.6.2"
"rollbar": {
"version": "0.3.1",
"dependencies": {
"node-uuid": {
"version": "1.4.1"
},
"lru-cache": {
"version": "2.2.4"
}
}
},
"redis": {
"version": "0.8.6"
@@ -434,6 +475,9 @@
"semver": {
"version": "1.1.4"
},
"strftime": {
"version": "0.6.2"
},
"mocha": {
"version": "1.14.0",
"dependencies": {

View File

@@ -1,7 +1,7 @@
{
"private": true,
"name": "windshaft-cartodb",
"version": "1.9.0",
"version": "1.10.2",
"description": "A map tile server for CartoDB",
"keywords": [
"cartodb"
@@ -22,16 +22,17 @@
"Sandro Santilli <strk@vizzuality.com>"
],
"dependencies": {
"node-varnish": "http://github.com/Vizzuality/node-varnish/tarball/v0.2.0",
"node-varnish": "http://github.com/Vizzuality/node-varnish/tarball/0.3.0",
"underscore" : "~1.3.3",
"windshaft" : "http://github.com/CartoDB/Windshaft/tarball/0.19.4",
"windshaft" : "http://github.com/CartoDB/Windshaft/tarball/0.20.0",
"step": "0.0.x",
"request": "2.9.202",
"cartodb-redis": "~0.3.0",
"redis-mpool": "http://github.com/CartoDB/node-redis-mpool/tarball/0.0.4",
"mapnik": "~0.7.22",
"mapnik": "http://github.com/Vizzuality/node-mapnik/tarball/0.7.26-cdb1",
"lzma": "~1.2.3",
"log4js": "~0.6.10"
"log4js": "~0.6.10",
"rollbar": "~0.3.1"
},
"devDependencies": {
"mocha": "1.14.0",

View File

@@ -620,6 +620,24 @@ suite('server', function() {
});
});
// See http://github.com/CartoDB/Windshaft-cartodb/issues/186
test("get'ing the grid of a private table should fail when unauthenticated (jsonp)",
function(done) {
assert.response(server, {
headers: {host: 'localhost'},
url: '/tiles/test_table_private_1/6/31/24.grid.json?callback=x',
method: 'GET'
},{}, function(res) {
// It's forbidden, but jsonp calls for status = 200
assert.equal(res.statusCode, 200, res.statusCode + ': ' + res.body);
// Still, we do NOT want to add caching headers here
// See https://github.com/CartoDB/Windshaft-cartodb/issues/186
assert.ok(!res.headers.hasOwnProperty('cache-control'),
"Unexpected Cache-Control: " + res.headers['cache-control']);
done();
});
});
// See http://github.com/Vizzuality/Windshaft-cartodb/issues/55
test("get'ing grid of private table should fail on unknown username",
function(done) {

View File

@@ -20,7 +20,8 @@ var helper = require(__dirname + '/../support/test_helper');
var windshaft_fixtures = __dirname + '/../../node_modules/windshaft/test/fixtures';
var CartodbWindshaft = require(__dirname + '/../../lib/cartodb/cartodb_windshaft');
var serverOptions = require(__dirname + '/../../lib/cartodb/server_options')();
var ServerOptions = require(__dirname + '/../../lib/cartodb/server_options');
var serverOptions = ServerOptions();
var server = new CartodbWindshaft(serverOptions);
server.setMaxListeners(0);
@@ -1167,12 +1168,37 @@ suite('template_api', function() {
assert.response(server, get_request, {},
function(res) { next(null, res); });
},
function checkTile(err, res) {
function checkTile_fetchOnRestart(err, res) {
if ( err ) throw err;
assert.equal(res.statusCode, 200,
'Unexpected error for authorized instance: '
+ res.statusCode + ' -- ' + res.body);
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
var cc = res.headers['x-cache-channel'];
assert.ok(cc);
assert.ok(cc.match, /ciao/, cc);
// hack simulating restart...
serverOptions = ServerOptions(); // need to clean channel cache
server = new CartodbWindshaft(serverOptions);
var get_request = {
url: '/tiles/layergroup/' + layergroupid + ':cb1/0/0/0/1.json.torque?auth_token=valid1',
method: 'GET',
headers: {host: 'localhost' },
encoding: 'binary'
}
var next = this;
assert.response(server, get_request, {},
function(res) { next(null, res); });
},
function checkCacheChannel(err, res) {
if ( err ) throw err;
assert.equal(res.statusCode, 200,
'Unexpected error for authorized instance: '
+ res.statusCode + ' -- ' + res.body);
assert.equal(res.headers['content-type'], "application/json; charset=utf-8");
var cc = res.headers['x-cache-channel'];
assert.ok(cc, "Missing X-Cache-Channel on fetch-after-restart");
assert.ok(cc.match, /ciao/, cc);
return null;
},
function deleteTemplate(err)

View File

@@ -76,7 +76,7 @@ if test x"$PREPARE_PGSQL" = xyes; then
sed "s/:PUBLICPASS/${PUBLICPASS}/" |
sed "s/:TESTUSER/${TESTUSER}/" |
sed "s/:TESTPASS/${TESTPASS}/" |
psql ${TEST_DB}
psql -v ON_ERROR_STOP=1 ${TEST_DB} || exit 1
fi

View File

@@ -38,7 +38,8 @@ if ( ! username ) usage(me, 1);
console.log("Using environment " + ENV);
global.environment = require('../config/environments/' + ENV);
var serverOptions = require('../lib/cartodb/server_options'); // _after_ setting global.environment
// _after_ setting global.environment
var serverOptions = require('../lib/cartodb/server_options')();
var client;
var dbname;