Coder Social home page Coder Social logo

windshaft-cartodb's Introduction

Windshaft-CartoDB Build Status

The CARTO Maps API tiler. It extends Windshaft and exposes a web service with extra functionality:

Build

Requirements:

Optional:

PostGIS setup

A template_postgis database is expected. One can be set up with

$ createdb --owner postgres --template template0 template_postgis
$ psql -d template_postgis -c 'CREATE EXTENSION postgis;'

Install

To fetch and build all node-based dependencies, run:

$ npm install

Run

You can inject the configuration through environment variables at run time. Check the file ./config/environments/config.js to see the ones you have available.

While the migration to the new environment based configuration, you can still use the old method of copying a config file. To enabled the one with environment variables you need to pass CARTO_WINDSHAFT_ENV_BASED_CONF=true. You can use the docker image to run it.

Old way:

$ node app.js <env>

Where <env> is the name of a configuration file under ./config/environments/.

Test

You can easily run the tests against the dependencies from the dev-env. To do so, you need to build the test docker image:

$ docker-compose build

Then you can run the tests like:

$ docker-compose run windshaft-tests

It will mount your code inside a volume. In case you want to play and run npm test or something else you can do:

$ docker-compose run --entrypoint bash windshaft-tests

So you will have a bash shell inside the test container, with the code from your host.

Coverage

$ npm run cover

Open ./coverage/lcov-report/index.html.

Docker support

We provide docker images just for testing and continuous integration purposes:

You can find instructions to install Docker, download, and update images here.

Useful npm scripts

Run test in a docker image with a specific Node.js version:

$ DOCKER_IMAGE=<docker-image-tag> NODE_VERSION=<nodejs-version> npm run test:docker

Where:

  • <docker-image-tag>: the tag of required docker image, e.g. carto/nodejs-xenial-pg1121:latest
  • <nodejs-version>: the Node.js version, e.g. 10.15.1

In case you need to debug:

$ DOCKER_IMAGE=<docker-image-tag> npm run docker:bash

Documentation

You can find an overview, guides, full reference, and support in CARTO's developer center. The docs directory contains different documentation resources, from a higher level to more detailed ones.

Contributing

Developing with a custom Windshaft version

If you plan or want to use a custom / not released yet version of windshaft (or any other dependency), the best option is to use npm link. You can read more about it at npm-link: symlink a package folder.

$ cd /path/to/Windshaft
$ npm install
$ npm link
$ cd /path/to/Windshaft-cartodb
$ npm link windshaft

Versioning

We follow SemVer for versioning. For available versions, see the tags on this repository.

License

This project is licensed under the BSD 3-clause "New" or "Revised" License. See the LICENSE file for details.

windshaft-cartodb's People

Contributors

alasarr avatar alberhander avatar algunenano avatar csobier avatar csubira avatar demimismo avatar dgaubert avatar elenatorro avatar esloho avatar fdansv avatar iagolast avatar ivanmalagon avatar javisantana avatar jesus89 avatar jgoizueta avatar juanignaciosl avatar lekum avatar luisbosque avatar manmorjim avatar matallo avatar moicalcob avatar namessanti avatar pnorman avatar rochoa avatar shylpx avatar simon-contreras-deel avatar thedae avatar tokumine avatar xavijam avatar zenitram avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windshaft-cartodb's Issues

test environment settings not making trough all testing

serverOptions:
{ base_url: '/tiles/:table',
  grainstore:
   { datasource:
      { user: 'tileuser',
        host: '127.0.0.1',
        port: 5432,
        srid: 4326,
        extent: '-20005048.4188,-20005048.4188,20005048.4188,20005048.4188',
        simplify: true } },
  redis:
   { host: '127.0.0.1',
     port: 6333,
     idleTimeoutMillis: 1,
     reapIntervalMillis: 1 },
  enable_cors: true,
  varnish_host: '',
  varnish_port: null,
  cache_enabled: false,
  log_format: '[:date] :req[X-Real-IP] \u001b[90m:method\u001b[0m \u001b[36m:req[Host]:url\u001b[0m \u001b[90m:status :response-time ms -> :res[Content-Type]\u
001b[0m',
  req2params: [Function],
  getInfowindow: [Function],
  getMapMetadata: [Function],
  flushCache: [Function] }

  ......[Mon, 09 Jul 2012 16:49:30 GMT] - GET 127.0.0.1:5555/ 200 3 ms -> text/html; charset=utf-8
.
....
....

  ✖ 14 of 15 tests failed:

  1) server get'ing blank style returns default style:
     Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused

Where does :6379 comes from if the server was configured with redis port 6333 ?

Database connection settings not honored

Windshaft is trying to connect to the wrong postgresql server (wrong port).

No matter what I write in all the environment configuration files it still tries 5432.
Doesn't honor PGPORT environment variable either.

Send CORS headers for all requests (when enabled)

When running main app and tiler on different TCP ports there are cross-domain issues (you get no response when using ajax).
This can be worked around by setting a configuration variable (enable_cors).

But such configuration is not used by all request types.
The ones served by windshaft have been fixed here: CartoDB/Windshaft#39

This ticket is to fix the ones served by Windshaft-cartodb (metadata, in particular)

@javisantana please scream here too if you see reasons not to do it.

Deleting "map_style" from redis doesn't trigger an error

While working on #18 I've had troubles with weird behaviors observed on redis key cleaning.
In particular the error found in Windshaft-cartodb log channel says:

FATAL:  database "cartodb_dev_user_2_db" does not exist (encountered during parsing of layer 'gshhs_c_l1' in map '/home/src/cartodb/')

While the database is clearly there (on the right port).

It basically looks like when an MML is missing from redis, something is re-creating one with default values.
And these defaults do not match the configured parameters for postgresql connection.

It is very confusing. I'd like much better an error than a failing attempt to workaround a trouble.
Especially when a default MML may give more authorization than a properly constructed one.

Only dump message on production error (no stack)

http://andrew.cartodb.com/tiles/neemo/1/1/2.png8?cache_buster=0&map_key=c1b5e152490185cb43b39382abe50b5b5ec2f284

Gives:

{"stack":"Error: Coordinates out of range: %d/%d/%d\n at MapnikSource.getTile (/home/ubuntu/www/Windshaft-cartodb/node_modules/windshaft/node_modules/tilelive-mapnik/lib/mapnik.js:306:25)\n at Function. (/home/ubuntu/www/Windshaft-cartodb/node_modules/windshaft/lib/windshaft/server.js:139:35)\n at next (/home/ubuntu/www/Windshaft-cartodb/node_modules/step/lib/step.js:51:23)\n at Object.getRenderer (/home/ubuntu/www/Windshaft-cartodb/node_modules/windshaft/lib/windshaft/render_cache.js:80:13)\n at Function. (/home/ubuntu/www/Windshaft-cartodb/node_modules/windshaft/lib/windshaft/server.js:134:30)\n at next (/home/ubuntu/www/Windshaft-cartodb/node_modules/step/lib/step.js:51:23)\n at Function.finishSetup (/home/ubuntu/www/Windshaft-cartodb/lib/cartodb/server_options.js:58:13)\n at next (/home/ubuntu/www/Windshaft-cartodb/node_modules/step/lib/step.js:51:23)\n at Function. (/home/ubuntu/www/Windshaft-cartodb/lib/cartodb/carto_data.js:131:17)\n at next (/home/ubuntu/www/Windshaft-cartodb/node_modules/step/lib/step.js:51:23)","message":"Coordinates out of range: %d/%d/%d"}

Add test for access to db when NO map key is known

One test in the req2param suite exposed a bug in "master" branch about accesses to a database for which there is no map_key generated being considered as authenticated (ie: "undefined" map_key specified, "undefined" map_key expected then all fine, log in as superuser).

I belive the bug is now fixed in "master" (and wasn't exposed in "develop"), but I think it'd make sense to have a focused test for this in the acceptance suite.

Potential rendering issue: markers truncated on tile boundary

When supplying very large point sizes and allow-overlap=false, they seem not to be rendered on neighboring tiles. I imagine this is similar to the issue that was solved with the CDB_ gridding methods,

https://examples.cartodb.com/tables/carto_tests/embed_map?sql=SELECT%20st_transform(st_setsrid(st_makepoint(10*x,10*x),4326),3857)%20as%20the_geom_webmercator%20FROM%20generate_series(-6,6)%20x

#carto_tests {
   marker-fill: #FF6600;
   marker-opacity: 1;
   marker-width: 28;
   marker-height: 38;
   marker-line-color: white;
   marker-line-width: 3;
   marker-line-opacity: 0.9;
   marker-placement: point;
   marker-type: ellipse;
   marker-allow-overlap: false;
   marker-spacing: 15;
   marker-max-error: 0.4;
}

Error: Postgis Plugin: bad connection

I was seeing complete tiles missing from the display of a map and when looking at the windshaft log file I found a bunch of:

[TILE RENDER ERROR]
Error: Postgis Plugin: bad connection

For other tiles it works fine so dunno what to look at.
Maybe a limit on number of client connections ?

test data needed

the acceptance test refers to tables that are not in the .sql provided so nobody can run the tests

it would be good to have the data in the repo :)

cc @tokumine

db_user Parameter in mapnik styles

I noticed there's a in the XML generated by grainstore.
I think it has to do with a parameter added in the configuration file for Windshaft-cartodb, which gets passed verbatim as the datasource of the XML.

The parameter was introduced when moving to PostgreSQL driven authentication, but doesn't need to be proxied to mapnik (it's for internal use only).

I don't like config.postgres to be fully proxied, btw. Anyway the fix here is likely to use a different setting for the db_user, rather than config.postgres

Thanks @lbosque for spotting this, btw

Expose Varnish cache TTL in configuration

Currently hard-coded in lib/cartodb/cartodb_windshaft.js:

            res.header('Cache-Control', 'no-cache,max-age=86400,must-revalidate, public');

Would be better exposed in the configuration

Posting a style doesn't update the style of maps served to unauthenticated requests

I belive unauthenticated requests will always be served tiles with the default style, no matter what you set when you POST a style. This is because when you POST you must be authenticated and being authenticated changes a different redis key than the one used by non authenticated requests.

This issue was introduced with the recent security fix preventing unautenticated access to private tiles.

This is an important bug, most likely affecting both the "develop" and the "master" branches.

It's critical to add a testcase for this in the server acceptance suite.

remove configuration files from repository

The config/environments/*.js files are configuration files, shouldn't be in the repository.
I think they should be either manually edited or created by a ./configure step.
There's an "config_off_repo" branch doing it.

TypeError: Cannot read property 'redis' of undefined

It happens when trying to start the application with node app.js production or node app.js development

This sounds like the change I made in 15162e8
which was basically to make Windshaft-cartodb actually use the
configuration parameters which were otherwise not used (specifically
the redis ones, for RedisPool).

Evidently I the application initializes "global.environment.redis" after
requiring that piece of code and thus the problem.

I'll see how to reorder inclusions for a quick fix, altought a better long
term fix would likely be turning CartoData into a real class...

Cleanup testing data after run

We currently create a database and a couple of users in the PostgreSQL cluster while running tests.
It would be wise to choose pseudo-random names for both db and users, and to remove them after the test has been run.

Timeout on "make check"

I'm getting many timeouts which are fixed by disconnecting my machine from the net.
Usually this is a sign of waiting for DNS lookup responses...

This ticket is to modify the tests environement to avoid DNS lookups.

npm install failing on mapnik and tilelive-mapnik

After running npm install it builds most dependencies and bombs out once it reaches [email protected]:

Waf: Leaving directory `/home/linuxadmin/dev/Windshaft-cartodb/node_modules/windshaft/node_modules/tilelive-mapnik-cartodb/node_modules/mapnik/build'
Build failed:  -> task failed (err #1): 
    {task: cxx node_mapnik.cpp -> node_mapnik_1.o}
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf -v configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf -v configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! error installing [email protected] Error: [email protected] install: `node-waf -v configure build`
npm ERR! error installing [email protected] `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! error installing [email protected]     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing [email protected]     at ChildProcess.emit (events.js:67:17)
npm ERR! error installing [email protected]     at ChildProcess.onexit (child_process.js:192:12)
npm ERR! [email protected] install: `node-waf -v configure build`
npm ERR! `sh "-c" "node-waf -v configure build"` failed with 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the mapnik package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-waf -v configure build
npm ERR! You can get their info via:
npm ERR!     npm owner ls mapnik
npm ERR! There is likely additional logging output above.
npm ERR! 
npm ERR! System Linux 3.0.0-12-generic-pae
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /home/linuxadmin/dev/Windshaft-cartodb
npm ERR! node -v v0.4.9
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
g++ -o obj/jsgc.o -c -Wall -Wno-format -MMD -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DLINUX -DX86_LINUX -DAVMPLUS_IA32 -DAVMPLUS_UNIX -DAVMPLUS_LINUX  -UDEBUG -DNDEBUG -UDEBUG_linuxadmin -DEDITLINE -I. -I./obj  -Os -fstrict-aliasing -fno-exceptions -fno-rtti -Wstrict-aliasing=2 jsgc.cpp
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/linuxadmin/dev/Windshaft-cartodb/npm-debug.log
npm not ok

I have a standard node v0.4.9 install at /usr/local/bin and all the dependencies installed according to the docs. Any ideas?

Add --with-geomfield configure switch

It may be useful to have switches to specify which geometry field is expected to contain the geometry to be rendered.
In addition to the name, we'll also need to know the SRID and, I think, the extent.

Fix global leaks

The acceptance tests reveal a few global "leaks". It takes removing the --ignore-leaks flag in mocha call in run_tests.sh to see it

cache_validator test fails with node-0.6 (in develop branch)

  ✖ 1 of 1 test failed:

  1) cache_validator should call purge on varnish when invalidate database:

  AssertionError: "purge obj.http.X-Cache-Channel == test_db:test_cache\n" == {"0":112,"1":117,"2":114,"3":103,"4":101,"5":32,"6":111,"7":98,"8":106,"9":46,"10":104,"11":116,"12":116,"13":112,"14":46,"15":8
      at /home/src/cartodb/Windshaft-cartodb/test/acceptance/cache_validator.js:36:20

Authenticated tiles request param name change

Right now to get authenticated tiles we use the param name map_key. On the other hand in the SQL API we use api_key. This difference produces a lot of problems for developers.

I propose we accept map_key and api_key. We will change eventually to api_key to be consistent, but for the time being having both would be great.

Points appear incomplete with some styles

Sometimes when a styled point exceeds the edges of a tile it appears cut.
It doesn't happen always. Not sure which situations cause this problem.
I can't see any error in windshaft log either.

I have a example in staging.cartodb.com:
https://staging.cartodb.com/tables/untitled_table_expor/embed_map

The applied style is:

untitled_table_expor {

marker-fill: #F1600F;
marker-opacity: 0.2;
marker-width: 78;
marker-line-color: white;
marker-line-width: 3;
marker-line-opacity: 0.9;
marker-placement: point;
marker-type: ellipse;
marker-allow-overlap: true;
}

Here there are two screenshots:
https://dl.dropbox.com/s/5e8mhfn7byfnip4/cut_points.png
https://dl.dropbox.com/s/y544d3z9zz0qxkv/cut_points2.png

Send PostgreSQL errors in the response body

It seems to me that when PostgreSQL errors occur they are not transported to the client, but just happen as logs on the server side. This is from "not authorized" accesses to database tables to SQL syntax errors.

The client only receives a 500 status code and an empty JSON.

Integrate README with requirements

 node app.js development 

node.js:134
        throw e; // process.nextTick error, or 'error' event on first tick
        ^
Error: libmapnik2.so.2.0: cannot open shared object file: No such file or directory

The README says nothing about libmapnik ?

Add tags for releases

I see there are no tags, nor releases on the npm registry.
Would be nice to start that (and a NEWS file)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.