consul/agent/structs
Paul Banks 74f2a80a42
Fix CA pruning when CA config uses string durations. (#4669)
* Fix CA pruning when CA config uses string durations.

The tl;dr here is:

 - Configuring LeafCertTTL with a string like "72h" is how we do it by default and should be supported
 - Most of our tests managed to escape this by defining them as time.Duration directly
 - Out actual default value is a string
 - Since this is stored in a map[string]interface{} config, when it is written to Raft it goes through a msgpack encode/decode cycle (even though it's written from server not over RPC).
 - msgpack decode leaves the string as a `[]uint8`
 - Some of our parsers required string and failed
 - So after 1 hour, a default configured server would throw an error about pruning old CAs
 - If a new CA was configured that set LeafCertTTL as a time.Duration, things might be OK after that, but if a new CA was just configured from config file, intialization would cause same issue but always fail still so would never prune the old CA.
 - Mostly this is just a janky error that got passed tests due to many levels of complicated encoding/decoding.

tl;dr of the tl;dr: Yay for type safety. Map[string]interface{} combined with msgpack always goes wrong but we somehow get bitten every time in a new way :D

We already fixed this once! The main CA config had the same problem so @kyhavlov already wrote the mapstructure DecodeHook that fixes it. It wasn't used in several places it needed to be and one of those is notw in `structs` which caused a dependency cycle so I've moved them.

This adds a whole new test thta explicitly tests the case that broke here. It also adds tests that would have failed in other places before (Consul and Vaul provider parsing functions). I'm not sure if they would ever be affected as it is now as we've not seen things broken with them but it seems better to explicitly test that and support it to not be bitten a third time!

* Typo fix

* Fix bad Uint8 usage
2018-09-13 15:43:00 +01:00
..
acl.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
acl_test.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
catalog.go agent: remove ConnectProxyServiceName 2018-06-14 09:41:49 -07:00
check_definition.go agent/config: support configuring alias check 2018-07-12 09:36:10 -07:00
check_definition_test.go Remove the script field from checks in favor of args 2018-05-08 15:31:53 -07:00
check_type.go agent/structs: check is alias if node is empty 2018-07-12 09:36:11 -07:00
connect.go More test tweaks 2018-06-25 12:25:13 -07:00
connect_ca.go Fix CA pruning when CA config uses string durations. (#4669) 2018-09-13 15:43:00 +01:00
connect_ca_test.go Fix CA pruning when CA config uses string durations. (#4669) 2018-09-13 15:43:00 +01:00
connect_test.go Added connect proxy config and local agent state setup on boot. 2018-06-14 09:41:57 -07:00
errors.go Makes RPC handling more robust when rolling servers. (#3561) 2017-10-10 15:19:50 -07:00
intention.go Fix some tests failures caused by the sorting change and some cuased by previous UpdatePrecedence() change 2018-06-25 12:25:13 -07:00
intention_test.go agent/consul: set precedence value on struct itself 2018-06-25 12:24:16 -07:00
operator.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
prepared_query.go agent/consul: support a Connect option on prepared query request 2018-06-25 12:24:12 -07:00
prepared_query_test.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
service_definition.go Implementation of Weights Data structures (#4468) 2018-09-07 15:30:47 +01:00
service_definition_test.go agent/structs: JSON marshal the configuration for a managed proxy 2018-06-25 12:25:12 -07:00
snapshot.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
structs.go Implementation of Weights Data structures (#4468) 2018-09-07 15:30:47 +01:00
structs_test.go Implementation of Weights Data structures (#4468) 2018-09-07 15:30:47 +01:00
testing_catalog.go agent/structs: validate service definitions, port required for proxy 2018-06-14 09:42:13 -07:00
testing_intention.go agent: use testing intention to get valid intentions 2018-06-14 09:41:43 -07:00
testing_service_definition.go agent/structs: validate service definitions, port required for proxy 2018-06-14 09:42:13 -07:00
txn.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00