open-consul/agent/consul/state
R.B. Boyer 64fc002e03
connect: fix failover through a mesh gateway to a remote datacenter (#6259)
Failover is pushed entirely down to the data plane by creating envoy
clusters and putting each successive destination in a different load
assignment priority band. For example this shows that normally requests
go to 1.2.3.4:8080 but when that fails they go to 6.7.8.9:8080:

- name: foo
  load_assignment:
    cluster_name: foo
    policy:
      overprovisioning_factor: 100000
    endpoints:
    - priority: 0
      lb_endpoints:
      - endpoint:
          address:
            socket_address:
              address: 1.2.3.4
              port_value: 8080
    - priority: 1
      lb_endpoints:
      - endpoint:
          address:
            socket_address:
              address: 6.7.8.9
              port_value: 8080

Mesh gateways route requests based solely on the SNI header tacked onto
the TLS layer. Envoy currently only lets you configure the outbound SNI
header at the cluster layer.

If you try to failover through a mesh gateway you ideally would
configure the SNI value per endpoint, but that's not possible in envoy
today.

This PR introduces a simpler way around the problem for now:

1. We identify any target of failover that will use mesh gateway mode local or
   remote and then further isolate any resolver node in the compiled discovery
   chain that has a failover destination set to one of those targets.

2. For each of these resolvers we will perform a small measurement of
   comparative healths of the endpoints that come back from the health API for the
   set of primary target and serial failover targets. We walk the list of targets
   in order and if any endpoint is healthy we return that target, otherwise we
   move on to the next target.

3. The CDS and EDS endpoints both perform the measurements in (2) for the
   affected resolver nodes.

4. For CDS this measurement selects which TLS SNI field to use for the cluster
   (note the cluster is always going to be named for the primary target)

5. For EDS this measurement selects which set of endpoints will populate the
   cluster. Priority tiered failover is ignored.

One of the big downsides to this approach to failover is that the failover
detection and correction is going to be controlled by consul rather than
deferring that entirely to the data plane as with the prior version. This also
means that we are bound to only failover using official health signals and
cannot make use of data plane signals like outlier detection to affect
failover.

In this specific scenario the lack of data plane signals is ok because the
effectiveness is already muted by the fact that the ultimate destination
endpoints will have their data plane signals scrambled when they pass through
the mesh gateway wrapper anyway so we're not losing much.

Another related fix is that we now use the endpoint health from the
underlying service, not the health of the gateway (regardless of
failover mode).
2019-08-05 13:30:35 -05:00
..
acl.go acl: a role binding rule for a role that does not exist should be ignored (#5778) 2019-05-03 14:22:44 -05:00
acl_test.go Simplified code in various places (#6176) 2019-07-20 09:37:19 -04:00
autopilot.go fix ignored errors in state store internals as reported by errcheck 2019-03-01 14:18:00 -06:00
autopilot_test.go Move autopilot to a standalone package 2017-12-11 16:45:33 -08:00
catalog.go Various Gateway Fixes (#6093) 2019-07-12 17:19:37 -04:00
catalog_test.go Fixed typos in comments (#6175) 2019-07-19 07:54:53 -04:00
config_entry.go connect: fix failover through a mesh gateway to a remote datacenter (#6259) 2019-08-05 13:30:35 -05:00
config_entry_test.go connect: detect and prevent circular discovery chain references (#6246) 2019-08-02 09:18:45 -05:00
connect_ca.go Implement Mesh Gateways 2019-07-01 16:28:30 -04:00
connect_ca_test.go connect/ca: prevent blank CA config in snapshot 2018-12-06 17:40:53 -08:00
coordinate.go Creates a registration mechanism for schemas. 2017-11-29 18:36:52 -08:00
coordinate_test.go Fill out the tests around coordinate/node functionality 2017-10-31 15:36:44 -07:00
delay.go Spelling (#3958) 2018-03-19 16:56:00 +00:00
delay_test.go pkg refactor 2017-06-10 18:52:45 +02:00
graveyard.go pkg refactor 2017-06-10 18:52:45 +02:00
graveyard_test.go pkg refactor 2017-06-10 18:52:45 +02:00
index_connect.go Add Proxy Upstreams to Service Definition (#4639) 2018-10-10 16:55:34 +01:00
index_connect_test.go Add Proxy Upstreams to Service Definition (#4639) 2018-10-10 16:55:34 +01:00
index_service_kind.go Implement Mesh Gateways 2019-07-01 16:28:30 -04:00
intention.go Fix hot loop in cache for RPC returning zero index. 2018-06-25 12:25:37 -07:00
intention_test.go fix typos reported by golangci-lint:misspell (#5434) 2019-03-06 11:13:28 -06:00
kvs.go kv: do not trigger watches when setting the same value (#5885) 2019-06-18 15:06:29 +02:00
kvs_test.go kv: do not trigger watches when setting the same value (#5885) 2019-06-18 15:06:29 +02:00
prepared_query.go Creates a registration mechanism for schemas. 2017-11-29 18:36:52 -08:00
prepared_query_index.go pkg refactor 2017-06-10 18:52:45 +02:00
prepared_query_index_test.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
prepared_query_test.go agent: fix formatting 2018-11-07 02:16:03 -08:00
schema.go Creates a registration mechanism for schemas. 2017-11-29 18:36:52 -08:00
schema_test.go pkg refactor 2017-06-10 18:52:45 +02:00
session.go Creates a registration mechanism for schemas. 2017-11-29 18:36:52 -08:00
session_test.go agent: move agent/consul/structs to agent/structs 2017-08-09 14:32:12 +02:00
state_store.go Fix Internal.ServiceDump blocking (#6076) 2019-07-04 16:17:49 +01:00
state_store_test.go Connect: Make Connect health queries unblock correctly (#5508) 2019-03-21 16:01:56 +00:00
tombstone_gc.go Sheds monotonic time info so tombstone GC bins work properly. 2017-11-29 10:34:24 -08:00
tombstone_gc_test.go Sheds monotonic time info so tombstone GC bins work properly. 2017-11-29 10:34:24 -08:00
txn.go txn: clean up some state store/acl code 2019-01-09 11:59:23 -08:00
txn_test.go api: add support for new txn operations 2018-12-12 10:54:09 -08:00