Rewrite the destination client and remove DNS fallback#259
Conversation
Signed-off-by: Eliza Weisman <[email protected]>
fixes linkerd/linkerd2#2728 Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
thanks @kleimkuhler
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
the existing discovery tests hit some of the fallback behaviour, but these new tests explicitly test fallback behavior around "no endpoints" responses. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
This test tests for behaviour that is no longer implemented. In particular, it asserts that when a new service is built that shares a destination authority with an existing resolution, any updates previously discovered for the existing resolution are also used for the new service without another Destination service query. Removing the caching and sharing of queries between multiple resolvers (the primary goal of this branch) makes it impossible for this test to pass. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
this way, the service will not be called if it is not ready when constructing the resolution. Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
olix0r
left a comment
There was a problem hiding this comment.
OK; I've run a test for the last ~12 hours -- this change does not resolve the memory leak issue we've been chasing; but otherwise, the change seems stable and good. Ship it!
It would be good to get another pair of eyes on this before merging, though...
@seanmonstar, if you have a chance today, would you mind taking a look at this branch? Thanks! |
Signed-off-by: Eliza Weisman <[email protected]>
Signed-off-by: Eliza Weisman <[email protected]>
|
I've done some additional manual testing on this branch, injecting the proxy into an nginx ingress controller. As of b0ade34, the proxy will now route outbound requests from the ingress controller to the correct backend, even when the ingress controller is not rewriting the A quick demonstrationNote that the ingress is not configured to add or rewrite any headers: However, The proxy logs confirm that the right thing happened: We may now want to update the ingress section in the documentation to reflect that rewriting |
seanmonstar
left a comment
There was a problem hiding this comment.
Wayyyy cleaner! Such love! 😍
When the Destination service returns a `NoEndpoints` response, a field
`exists` is set if the destination _does_ exist in service discovery
but has no endpoints. The API spec states that:
> `no_endpoints{exists: false}` indicates that the service does not exist
> and the client MAY try an alternate service discovery method (e.g. DNS).
>
> `no_endpoints(exists: true)` indicates that the service does exist and
> the client MUST NOT fall back to an alternate service discovery
> method.
When the DNS fallback behaviour was removed from the proxy in #259, this
field was overlooked, and the proxy was changed to fall back to original
destination routing _any_ time the control plane indicates that no
endpoints exist for a destination. This is incorrect, as the proxy
should always treat the destination service as authoritative.
Additionally, this means that requests to endpoints which are known to
not exist will construct an unnecessary client service, and eventually
fail with a 502 error when the upstream client connection to the
non-existant endpoint ultimately fails.
This branch changes the `control::destination::resolution::Daemon`
future to only send `Update::NoEndpoints` (which indicates that the load
balancer should fall back) to the load balancer when the Destination
service response has `exists: false`, or on `InvalidArgument` errors,
and _not_ when a `no_endpoints{exists: true}` response is recieved.
These requests will now fail fast with a 503 error rather than
attempting an ultimately futile fallback request.
Previously, one of the discovery tests expected the incorrect behaviour.
I've changed this test to now expect that destinations known to not
exist do _not_ fall back, and renamed it from
`outbound_falls_back_to_orig_dst_when_destination_has_no_endpoints` to
`outbound_fails_fast_when_destination_has_no_endpoints`. I've also
confirmed that the updated test fails against master and passes after
this change.
Fixes linkerd/linkerd2#2880
Signed-off-by: Eliza Weisman <[email protected]>
When the DNS fallback behavior was removed from the proxy in #259, the proxy was changed to fall back to original destination routing _any_ time the control plane indicates that no endpoints exist for a destination. This is incorrect, as the proxy should always treat the destination service as authoritative. Additionally, this means that requests to endpoints which are known to not exist will construct an unnecessary client service, and eventually fail with a 502 error when the upstream client connection to the non-existent endpoint ultimately fails. Instead, the proxy should only fall back when the destination is outside the search suffixes or the Destination service returns an `InvalidArgument` response. This is a much larger change than #263. In particular, the fallback behavior has been moved from when the the actual client service is called to when the client service is _constructed_, as we do not expect to recieve an `InvalidArgument` response on a Destination query that has previously recieved updates. This was implemented by changing the `Resolve` trait to return a `Future` whose `Item` type is a `Resolution`, rather than returning a `Resolution`. When the Destination query returns `InvalidArgument`, the future will fail. The `proxy::http::fallback` middleware has been changed so that rather than making both the primary and fallback service and falling back on a per-request basis, it tries to make the primary service, and falls back if the primary `MakeService` future fails. Although this is a large change, I think the resulting code is simpler and more elegant than the previous approach. Previously, one of the discovery tests expected the incorrect behavior. I've changed this test to now expect that destinations known to not exist do _not_ fall back, and renamed it from `outbound_falls_back_to_orig_dst_when_destination_has_no_endpoints` to `outbound_fails_fast_when_destination_has_no_endpoints`. I've also confirmed that the updated test fails against master and passes after this change. Fixes linkerd/linkerd2#2880 Closes #263 Signed-off-by: Eliza Weisman <[email protected]>
This branch removes the fall-back-to-DNS behaviour from the proxy's
destination module. Instead, when the Destination service returns "no
endpoints", the proxy will route the request to its original
destination, using the fallback behaviour introduced in #248.
In addition, the proxy now no longer reconnects to the destination
service for queries which receive a response with the Invalid Argument
status code. After linkerd/linkerd2#2664, this status is used by the
control plane to indicate names which should not query the destination
service. I've added a new test for this.
Furthermore (and unlike #245), this branch also removes the caching of
service discovery lookups so that they can be shared between resolvers
for authorities with the same canonical form. When we limited the number
of concurrently in flight destination service queries to 100, reusing
them was much more important; now it adds a lot of unnecessary
complexity.
The rewritten
control::destinationmodule is now much simpler and(hopefully) easier to understand. The
Resolverholds a destinationservice
Client, which is cloned every time a newResolutionisrequested. Each active
Resolutionhas a corresponding background taskthat drives the destination service query and sends updates through a
channel to the
Resolver.The background task is necessary so that updates are processed as they
are recieved, rather than only when the
Resolutionis polled (i.e.when the load balancer is routing a request). In addition, the channel
provides the queueing necessary to transform the control plane's update
types (which contain multiple endpoint addresses) into multiple
tower-balanceupdates for single endpoints, and to invalidate staleendpoints when the control plane connection is reestablished. When a
control plane query is not necessary because the requested authority
does not match the proxy's destination suffixes, the background task is
not spawned and the
Resolutionremains permanently in the "noendpoints" state; and when an
InvalidArgumenterror code is recieved,the background task terminates.
A majority of the service discovery tests pass with no changes after
this change. The following changes were necessary:
outbound_updates_newer_serviceswas removed, as it teststhat the same destination service query is shared between multiple
services with the same authority (which is no longer the case).
Unavailablestatus code when it has run out of expected destinations, rather than
InvalidArgument, as that code is used to indicate that a destinationshould never be reconnected.
exist, and for not reconnecting after an
InvalidArgumenterror.Closes #245.
Closes linkerd/linkerd2#2661
Closes linkerd/linkerd2#2728
Signed-off-by: Eliza Weisman [email protected]