-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
connect: fix failover through a mesh gateway to a remote datacenter #6259
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. One big question about the config/flexibility but the code otherwise looks good to me.
agent/xds/failover_math.go
Outdated
} | ||
} | ||
|
||
return primary // if everything is broken just use the primary for now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think about making the healthy threshold configurable? That was what we talked about in the original domain model RFC (i.e. failover if some percentage of nodes is unhealthy).
It seems simple to built here, I think the big downside is that Envoy doesn't exactly support that model so if it does fix weighted clusters to be able to set separate SNI per leg or similar we won't be able to use it as it won't exactly provide "healthy threshold" semantics.
Given that no other proxies work exactly like Envoy in this sliding failover case, what do you think about introducing a healthy_threshold_percent
now which is the percentage of services that must be healthy to keep traffic flowing to them and not failover. Then if we want to re-introduce more complex "sliding" mechanism for Envoy later we could be explicit and add it as a separate mutually exclusive option like sliding_failover_overprovision_factor
.
I think that's OK UX esp. given that this mode is one we can always implement for any proxy as we are in control and most other proxies are more likely to be able to do something like this than they are to do something with same semantics as Envoy over provisioning/weighting?
If the answer is that we'd rather ship like this I think that's OK but I feel like "wait til every single instance is dead" although that's what prepared queries do is not really an ideal strategy in a modern Service Mesh. It basically only works with extremely low numbers of replicas and low request volume. Everything else is just a prolonged cascading failure until at last the remaining nodes are overwhelmed and fail health checks and traffic shifts but then the overwhelmed nodes catch up and get "healthy" and traffic flaps back etc...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this to a new issue as it's purely additive: #6276
7bddbec
to
247756e
Compare
7955d77
to
cf62afd
Compare
72a55eb
to
534a9f5
Compare
cf62afd
to
4d263ea
Compare
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).
4d263ea
to
08406fa
Compare
…this test be incorrect
@@ -188,6 +189,11 @@ func TestDiscoveryChainRead(t *testing.T) { | |||
Kind: structs.ServiceResolver, | |||
Name: "web", | |||
ConnectTimeout: 33 * time.Second, | |||
Failover: map[string]structs.ServiceResolverFailover{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the compiler patch above the gateway customization is now correctly ignored so this test wasn't testing one of the customizations. Adding a dc2 failover causes it to continue being customized by gateway mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Just a few questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(NOTE: This is a simpler variation of a solution to #6161 than was proposed in PR #6254)
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:
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:
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.
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.
The CDS and EDS endpoints both perform the measurements in (2) for the
affected resolver nodes.
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)
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.
Fixes #6161