Add Topology ATS Config Generation#4790
Conversation
|
With the merging of #4807, would you like to account for |
|
Now that #4724 is merged, there's a |
There was a problem hiding this comment.
With first/inner/last header rewrite now it might make sense for this function to specify which of those 3 buckets the server is in and use this when generating those configs.
There was a problem hiding this comment.
Maybe. I'll make it do whatever makes the most sense when I add those Header Rewrites to the generation. Not sure what that'll be until I start changing it.
There was a problem hiding this comment.
This function appears to basically duplicate the makeDSTopologies function in remapdotconfig.go except for the == nil checks and using tc.DeliveryServiceNullable. Can they be consolidated and shared?
There was a problem hiding this comment.
Not without a function to translate RemapConfigDSData to DeliveryServiceNullable, which would be even more code.
The non-API types like RemapConfigDSData exist in order to reduce duplication and unnecessary queries in TO. I'd like to remove them and change all the atscfg funcs to take standard API objects, but I was waiting until the config files were removed from the TO API.
There was a problem hiding this comment.
The error message should say hosting.config, but if this function is consolidated with makeDSTopologies maybe it should be left to the caller to prepend the Making *.config context.
There was a problem hiding this comment.
Rather than sending context down, I think it would be cleaner to propagate the error up and add the context in the caller. Most of config gen doesn't use errors now, because it needed to emulate the Perl in the TO API.
Once that's done, many functions like this will also distinguish between fatal and non-fatal errors.
I changed it to "hosting.config" for now, and added a TODO to propagate once config gen is returning errors properly.
There was a problem hiding this comment.
I imagine this comment was helpful for developing this PR but probably isn't needed anymore.
There was a problem hiding this comment.
Yep, accidentally left in. Removed.
There was a problem hiding this comment.
So for MSO purposes I think we may need to include ORG_LOC cachegroups in topologies. So a more valid check for this is probably that there are no parents or the parents are all ORG_LOC.
There was a problem hiding this comment.
So, it's been a few weeks, I'll have to verify, but I'm pretty sure the rest of the Topology Config expects that.
I believe I wrote it expecting MSO Origins to be the "last tier," and everything generates correctly. In terms of the remapping config, the last tier is no different than an intermediary tier, and multiple MSO origins are set as parents exactly the same way as multiple Mid parents.
That said, that may not work with the First/Middle/Last Header Rewrites. I'm planning to start implementing those soon, so hopefully I'll verify then.
I seem to recall it being very clean and elegant how MSO Origins were treated like any other server in the generation, I think it would be nice to preserve that if possible.
There was a problem hiding this comment.
I think this needs to check the required capabilities before generating a remap line for a given DS, right?
There was a problem hiding this comment.
I think this needs to check the required capabilities before generating a remap line for a given DS, right?
There was a problem hiding this comment.
This comment should include the topology name as well
There was a problem hiding this comment.
Do we need to take capabilities into account when determining whether or not a given header-rewrite should be generated for a cache? I suppose as long as the remap is omitted in that case, the header-rewrite configs are just cruft.
There was a problem hiding this comment.
Probably, but yeah, not critical.
Header rewrites are their own file, so the place to do that is the meta gen.
The assignedEdges here are only used to calculate Max Origin Connections. The change here is just saying "if the DS is in a Topology, include the Edge in the Assigned count for MaxOriginConns."
3f73867 to
0742063
Compare
|
@rob05c - does this PR add the value of ds.max_origin_conns to header_rewrite_last_dsname.config |
|
Yep, Max Origin Conns is in there, on the LastHeaderRewrite: https://github.com/apache/trafficcontrol/pull/4790/files#diff-4943b4d6fbf18539076e8631e37f740cR98 |
zrhoffman
left a comment
There was a problem hiding this comment.
toreq.GetServerUpdateStatus() calls the API 1.4 version of GET /servers/{host_name}/update_status. Since #4901 only adds Flexible Topologies support for API 3.0 version of GET /servers/{host_name}/update_status, atstccfg won't get accurate parent_pending and parent_reval_pendinginfo if it uses API 1.4 for this route.
There was a problem hiding this comment.
If the immediate parent cachegroup has no servers in it GetTopologyParents(), returns empty arrays, even if there are servers in further ancestor topology nodes. Should it keep going until it finds a topology node with a non-empty cachegroup?
There was a problem hiding this comment.
On second thought, maybe we should perform validation to make sure a topology node's cachegroup contains at least 1 server.
There was a problem hiding this comment.
(That validation would occur in TO and is outside the scope of this PR)
There was a problem hiding this comment.
I've been trying to log errors on every possible bad data the config gen can receive.
I'd agree with doing the validation in TO, but also logging an error in the config gen. I'll make it do that
There was a problem hiding this comment.
Ok, I made it log the error
Adds ORT location param inference. If location Parameters do not exist the files are created and added anyway with the directory determined from the local ATS install, for: - cache.config - hosting.config - ip_allow.config - parent.config - plugin.config - records.config - remap.config - storage.config - volume.config - Delivery Services with - Edge Header Rewrite - Mid Header Rewrite, - Cache URL - URL Sig - URI Signing Note this is not an exhaustive of required files, and many files must be dynamic and cannot be inferred. But this does remove the manual configuration for this list. More files may be added in the future.
Refactors parent.config generation to have a single DS for-loop, instead of different loops for top-level vs non-top-level caches. This is to prepare for Topologies, which will need their own behavior, irrespective of "top level" Edge vs Mid, for every DS.
Also adds a TODO to propogate, once config gen returns errors.
de1c7fc to
4b65101
Compare
Necessary because the latest API considers Topologies, previous API doesn't.
Fixed - ORT/atstccfg will now use the latest API if it exists, and fall back to the prior if it doesn't. |
|
--- FAIL: TestMakeParentDotConfigTopologies (0.00s)
parentdotconfig_test.go:488: expected parent 'dest_domain=ds0.example.net', actual: '# DO NOT EDIT - Generated for myserver by myToolName (https://myto.example.net) on Tue Aug 4 21:44:15 UTC 2020
dest_domain=ds0.example.net port=80 parent="" round_robin=consistent_hash go_direct=false qstring=myQStringHandlingParam
dest_domain=. parent="" round_robin=consistent_hash go_direct=false qstring=myQstringParam
'
--- FAIL: TestMakeParentDotConfigTopologiesCapabilities (0.00s)
parentdotconfig_test.go:721: expected parent 'dest_domain=ds0.example.net' without required capabilities: '# DO NOT EDIT - Generated for myserver by myToolName (https://myto.example.net) on Tue Aug 4 21:44:15 UTC 2020
dest_domain=. parent="" round_robin=consistent_hash go_direct=false qstring=myQstringParam
'
parentdotconfig_test.go:724: expected parent 'dest_domain=ds1.example.net' with necessary required capabilities, actual: '# DO NOT EDIT - Generated for myserver by myToolName (https://myto.example.net) on Tue Aug 4 21:44:15 UTC 2020
dest_domain=. parent="" round_robin=consistent_hash go_direct=false qstring=myQstringParam
'
FAIL
exit status 1
FAIL github.com/apache/trafficcontrol/lib/go-atscfg 0.007s |
Ah, the code was right, just the latest Capability changes broke the tests, needed more data. |
| } | ||
|
|
||
| return len(serverNode.Parents) == 0, true | ||
| topologyHasChildren := false |
There was a problem hiding this comment.
A name like topologyNodeHasChildren or nodeHasChildren might make more sense here
| for _, node := range topology.Nodes { | ||
| for _, parent := range node.Parents { | ||
| if parent == serverNodeIndex { | ||
| topologyHasChildren = true | ||
| break | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Should break out of the outer loop if topologyHasChildren is true
There was a problem hiding this comment.
Yeah, it's not a bug, just less efficient. I'll fix.
| for _, to := range topologies { | ||
| if to.Name == *ds.Topology { | ||
| topology = to | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
We have a tc.DeliveryServiceNullable array and a tc.Topology array in this scope, consider calling atscfg.hostingMakeDSTopologies() to get a topologies by DS name map so that running time is number of DSes + number of Topologies instead of number of DSes * number of Topologies like it currently is.
There was a problem hiding this comment.
I went back and forth whether to use a map for these. The performance doesn't matter, unless someone had on the order of a million topologies, the network cost vastly outweighs this. But I don't really object, I'll change them
| for _, to := range topologies { | ||
| if to.Name == *ds.Topology { | ||
| topology = to | ||
| break | ||
| } | ||
| } |
There was a problem hiding this comment.
Another place where a topologies by DS name map would be useful (though it doesn't make sense to build it here).
|
|
||
| // Topologies must be all the topologies for the server's cdn. | ||
| // May incude topologies of other cdns. | ||
| Topologies []tc.Topology |
There was a problem hiding this comment.
Is there any advantage to having topologies not assigned to any DS? If not, including a topologies by DS name map in TOData instead of a topology array might make more sense, since there are several places where we need to get a topology, given a certain DS.
There was a problem hiding this comment.
I'd like to keep TOData as the raw data from Traffic Ops, in order to make the config gen library lib/go-atscfg more flexible.
As soon as the config routes are removed from TO, the plan is to change lib/go-atscfg to take standard API objects.
If we do pre-processing like putting things in maps in ORT/atstccfg, and pass pre-processed data to lib/go-atscfg, then atscfg is harder to use for anyone wanting to just make a TO request for the necessary data and pass it to a config gen func.
There was a problem hiding this comment.
Good point, that makes more sense in the long run.
Optimization.
Per code review.
More performant for large numbers of topologies. Per PR review.
There was a problem hiding this comment.
- Code is formatted correctly
- Unit tests pass
- atstccfg respects Topologies parentage but only for topology-based DSes, ATS serves requests appropriately
- Non-topology-based DSes continue to work with DeliveryServiceServers as expected
- FirstHeaderRewrite/InnerHeaderRewrite/LastHeaderRewrite rules are places on the appropriate caches
LGTM!
Adds Topologies to ATS Config Generation.
Includes tests.
No docs, docs already exist for Topologies, and details of config gen aren't documented.
Includes changelog.
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
Run tests.
Create Topologies in TO/TP with a Server, and a Delivery Service. Run ORT on that Server, and verify the config generated is correct. Verify servers not in a topology aren't included. Verify DSes without Topologies still use DeliveryServiceServers appropriately. Verify ATS loads config and serves requests to the DS appropriately.
If this is a bug fix, what versions of Traffic Control are affected?
Not a bug fix.
The following criteria are ALL met by this PR
Additional Information