apache / trafficcontrol

Apache Traffic Control is an Open Source implementation of a Content Delivery Network
https://trafficcontrol.apache.org/
Apache License 2.0
1.04k stars 339 forks source link

Add ability to bulk change DNS TTLs on delivery services #2161

Open elsloo opened 6 years ago

elsloo commented 6 years ago

Traffic Ops needs to have an API that will allow one to perform bulk changes to DNS TTLs on delivery services. Specifically, we need to be able to lower the DNS TTLs on all HTTP delivery services on a given CDN to allow us to perform maintenance on Traffic Router. We need to lower DNS TTLs on HTTP delivery services so that a Traffic Router drops out of the routing name RRset when set to ADMIN_DOWN in a reasonable timeframe.

This currently must be done directly in the database, making this very difficult for operations.

mitchell852 commented 3 years ago

unfortunately, the TO api does not (currently) support bulk updates, however, this could be achieved via a script. reviewed in 7/13/2021 working group. leaving as is.

rob05c commented 3 years ago

this could be achieved via a script

Not safely. Issuing multiple requests has race conditions, and results in temporarily malformed data in Traffic Ops, potentially permanently if some requests fail.

Rather than a specific "POST bulk-dns-ttl", I think we should add a generic ability to make bulk requests, which share the same DB transaction, and are therefore Atomic and Isolated.

It shouldn't be too hard to do. It's not trivial, but we could add a format that's essentially

{"multi-request": [{ "path": "/api/3.1/foo", "method": POST, "headers": {"key":"val"}, "body": "foo" }]} That returns a {"responses":[{"response": ...

Which would call the handlers for the given path, with a single DB transaction, and return the results of each.

Again, not trivial, but probably not much more work than adding a single dedicated bulk endpoint like post-bulk-dns-ttl.

And it's something we especially need for Ops automation. Ops scripts often need to update a number of fields all at once, and having to do that separately has race conditions, and results in temporarily invalid data in Traffic Ops (potentially permanently, if early requests succeed and later ones fail).

We need a bulk request feature, to allow Ops automation to safely, atomically update multiple things.