Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic configuration #58

Open
ingenieroariel opened this issue Aug 3, 2016 · 23 comments
Open

Dynamic configuration #58

ingenieroariel opened this issue Aug 3, 2016 · 23 comments

Comments

@ingenieroariel
Copy link

GeoNode has a use case for Tegola where configuration should be passed at runtime.

It would be great to be able to use something other than files on a disk to support this.

@gdey
Copy link
Member

gdey commented Aug 3, 2016

@ARolek @jj0hns0n What do you think about this? I think it makes sense, but we have to think about things like Security, and how do we persist the changes.

@ARolek
Copy link
Member

ARolek commented Aug 3, 2016

Random idea, what if the --config-file flag supported an HTTP path? You could then store the config in one location, and fire a "reload" signal to the tegola server and it would fetch the config file.

@gdey
Copy link
Member

gdey commented Aug 3, 2016

We could tell the different from a regular file by looking to see that it starts with https?:// to determine if it's a url or not. Is that what you are thinking. Otherwise we assume it's a file? Or do you think we should force it to always be a url, and files start with file://?

@ARolek
Copy link
Member

ARolek commented Aug 3, 2016

For ease of use we would assume it's a local file unless it has a protocol in front of it (i.e. http(s))

@ingenieroariel
Copy link
Author

I tested this in my local machine:
curl file:///code/hhypermap/101.diff
and it worked fine. Curl already handles all kinds of urls (local filesystem or remote) nicely.

@ingenieroariel
Copy link
Author

I am trying to think through how it would work with docker, this solution leads to something that may not make sense in that context (having to let my webapp know about tegola and tegola about my webapp).

# docker-compose.yml
version: '2'
services:
  postgres:
    image: postgres
    ports:
      - "5432:5432”

   django:
     image: django
     volumes:
       - .:/code
     command: python manage.py runserver 0.0.0.0:8000
     ports:
       - “8000:8000”
     links:
       - postgres
       - tegola
     environment:
       - TEGOLA_RELOAD_URL=http://tegola/reload

  tegola:
     image: terranodo/tegola
     command: -config-file=http://django/tegola/config.yml
     links:
       - postgres
       - django
     ports:
        - "9090:9090”

@george-silva
Copy link

Hello all! Just chiming in here.

I've built something like this for Tilestache, but it fetched from a http(s) endpoint. This is extremely useful and it's one of the features preventing me to switch to tegola.

I would actually change django-tilestache to support both servers.

@ARolek
Copy link
Member

ARolek commented Aug 29, 2018

@george-silva tegola supports loading a config over http(s), just pass in a URL to the --config flag. We don't have runtime reloading in yet though. Do you need reloading the config for your use case?

@george-silva
Copy link

george-silva commented Aug 29, 2018

Yes. That's one of the main usecases. Because there are some apps of ours that allows users to define their own tables/layers (within some limitations, of course), but it would be great if it was dynamic, instead of needing to restart the whole service.

In django-tilestache I just added a timer that re fetches the config from the http(s) endpoint configured, for example.

On the other hand, I just saw this: https://github.com/go-spatial/tegola/tree/master/cmd/tegola_lambda which might work for my usecase.

One thing does not rule out the other because lambdas are a whole new department (and only works on AWS), but it's very cool to known that you already support it.

@ARolek
Copy link
Member

ARolek commented Aug 29, 2018

@george-silva got it. In an ideal world would how would you like to issue the reload command?

And yep, Lambda support is recently released. I just heard GCP has native Go functions coming soon too.

@george-silva
Copy link

george-silva commented Aug 29, 2018 via email

@ARolek
Copy link
Member

ARolek commented Aug 31, 2018

@george-silva I was thinking more along the lines of sending a signal to a running tegola process. The endpoint idea is something I'm trying to avoid as I don't like the idea of having a reload endpoint publicly available. If we did want to support an endpoint we could potentially support a configurable secret that would be required to invoke the endpoint. I'm open for ideas on this.

Regarding implementing this feature, I'm happy to provide codebase direction if you want to work on it. It's going to take some thinking to figure out the best strategy. We have to consider remote loading (so possible network errors), config validation and then a swap of the map configs in the atlas system. The good thing is the design of atlas did consider this situation so it shouldn't be too much work to get it in. I would start by looking into the way the config is loaded & validated first and then understand how the subsystems are instantiated.

We could also look into the the UX for nginx's reload functionality as they provide something similar.

@george-silva
Copy link

But how can we inform, from the outside, that the config changed?

Since there is support for http(s), it would be simple to implement a timed operation for this reload, right? Could be an option to pass along to run the process.

The endpoint for sure would need a secret token for that. What we could do is: when asked to reload, the server tries to reload the new config (from file or from http(s)) and if it's invalid, we just return a bad response and keep the old config.

Both options seem feasible. A timed reload would be simpler to implement and basically configures the server to pull data from a URL. An endpoint could have similar behavior or could be more complex (like providing a new config).

Thoughts?

@digitaltopo
Copy link

I'm also interested if there's a way to make dynamic queries to the postgres database with tegola, and generate tiles in "realtime"

@ARolek
Copy link
Member

ARolek commented Mar 14, 2019

@digitaltopo this thread is about dynamic configuration. Are you interested in changing the configuration (i.e. the queries) or just serving data directly from the database rather than a cache?

@digitaltopo
Copy link

@ARolek I am interested in both:

  1. Serve data directly from the database
  2. Queries (request tiles with a query... aka define a layer with a query then request tiles)

Apologies if this is the wrong thread to post in, I'm new to Tegola, and looking at the docs, it appeared that in order to setup specific layers (using SQL queries) you have to have them available in the configuration (https://tegola.io/documentation/configuration/#postgis-1). I am trying to understand if a query can be sent at runtime in order to dynamically generate a new set of tiles, by running an arbitrary SQL query. I don't know how the cache would fit into this scenario, but I'd love to hear an outline of how this works. Thank you!

@dBitech
Copy link

dBitech commented Mar 14, 2019 via email

@digitaltopo
Copy link

I understand that Tegola's server capabilities don't allow for queries via a uri request, but could I build a an http server in front of Tegola that generated new provider.layer configs and passed them to Tegola? It sounds like right now once Tegola is running, the configurations cannot be swapped out, correct?

@dBitech
Copy link

dBitech commented Mar 14, 2019 via email

@digitaltopo
Copy link

@dBitech Thank you for clarifying. So next question, would it be appropriate to try to replicate the desired behavior by using Tegola as a serverless function, with AWS Lambda or Google Cloud Functions?

@dBitech
Copy link

dBitech commented Mar 14, 2019 via email

@ARolek
Copy link
Member

ARolek commented Mar 19, 2019

@digitaltopo there is currently a version of tegola for lambda. We have the prebuilt binaries on the release page and instructions in the tegola_lambda README. It's fairly easy to get going but there are some gotchas I tried to capture in the README. As @dBitech pointed out there is startup overhead using serverless, but depending on how you configure your infrastructure over time your caching layers (i.e. CDN) will be handling a lot of the traffic. Ultimately it depends on your requirements if this is a viable strategy or not.

Regarding dynamic configuration, I played with some config hot swap strategies awhile back and it's completely doable. There will be a moment where requests will be locked as the new config is parsed and tested prior to overwriting the previous config. This has just not been a priority to implement so far. Would you be interested in tackling it?

@stdmn
Copy link

stdmn commented Jul 10, 2019

Moved to #613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants