-
Notifications
You must be signed in to change notification settings - Fork 273
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
Decouple client connection metadata from the I/O type #1426
Conversation
Instead of using tower's `MakeConnection` trait, we use our own trait so that we can introduce connection metadata in a followup change.
Some information about client connections may not be known a priori. For example, the local socket address is only known after the connection is established and the TLS handshake may negotiate additional information (like the ALPN protocol). We can use traits on the I/O type, but this means that all wrappers types need implement all of these traits. This is cumbersome. This change replaces the `tower::make::MakeConnection` helper trait with a new `linkerd_stack::MakeConnection` trait that explicity returns a `Metadata` instance so that connectors can return arbitrary information. Now, the TCP connector returns a `Local<ClientAddr>` and the TLS connector conditionally includes the negotiated protocol. This change sets up the ability for the HTTP client to negotiate protocol upgrading via ALPN instead of using per-request headers.
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 --- not having to implement a bunch of additional traits on every I/O wrapper type seems much nicer IMO. i commented on several minor style nits, but I didn't see any blockers! :)
let local_addr = io.local_addr()?; | ||
debug!( | ||
local.addr = %io.local_addr().expect("cannot load local addr"), | ||
local.addr = %local_addr, |
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 will now bail rather than panicking if the local address is missing...is that what we want? should we be logging an error or something before bailing?
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 will manifest as a connection error and be logged where those errors are handled.
In addition to dependency updates, this change updates the inbound proxy to handle opaquely transported HTTP traffic. This fixes an issue encountered when a `Service`'s opaque ports annotation does not match that of the pods in the service. This situation should be rare. --- * Handle HTTP traffic over opaque transport connections (linkerd/linkerd2-proxy#1416) * build(deps): bump tracing-subscriber from 0.3.3 to 0.3.4 (linkerd/linkerd2-proxy#1421) * build(deps): bump pin-project from 1.0.8 to 1.0.9 (linkerd/linkerd2-proxy#1422) * build(deps): bump tracing-subscriber from 0.3.4 to 0.3.5 (linkerd/linkerd2-proxy#1423) * build(deps): bump pin-project from 1.0.9 to 1.0.10 (linkerd/linkerd2-proxy#1425) * build(deps): bump http from 0.2.5 to 0.2.6 (linkerd/linkerd2-proxy#1424) * build(deps): bump serde_json from 1.0.73 to 1.0.74 (linkerd/linkerd2-proxy#1427) * Decouple client connection metadata from the I/O type (linkerd/linkerd2-proxy#1426) * tests: rename 'metrics' addr to 'admin' (linkerd/linkerd2-proxy#1429)
In addition to dependency updates, this change updates the inbound proxy to handle opaquely transported HTTP traffic. This fixes an issue encountered when a `Service`'s opaque ports annotation does not match that of the pods in the service. This situation should be rare. --- * Handle HTTP traffic over opaque transport connections (linkerd/linkerd2-proxy#1416) * build(deps): bump tracing-subscriber from 0.3.3 to 0.3.4 (linkerd/linkerd2-proxy#1421) * build(deps): bump pin-project from 1.0.8 to 1.0.9 (linkerd/linkerd2-proxy#1422) * build(deps): bump tracing-subscriber from 0.3.4 to 0.3.5 (linkerd/linkerd2-proxy#1423) * build(deps): bump pin-project from 1.0.9 to 1.0.10 (linkerd/linkerd2-proxy#1425) * build(deps): bump http from 0.2.5 to 0.2.6 (linkerd/linkerd2-proxy#1424) * build(deps): bump serde_json from 1.0.73 to 1.0.74 (linkerd/linkerd2-proxy#1427) * Decouple client connection metadata from the I/O type (linkerd/linkerd2-proxy#1426) * tests: rename 'metrics' addr to 'admin' (linkerd/linkerd2-proxy#1429)
Some information about client connections may not be known a priori. For
example, the local socket address is only known after the connection is
established and the TLS handshake may negotiate additional information
(like the ALPN protocol).
We can use traits on the I/O type, but this means that all wrappers
types need implement all of these traits. This is cumbersome.
This change replaces the
tower::make::MakeConnection
helper trait witha new
linkerd_stack::MakeConnection
trait that explicity returns aMetadata
instance so that connectors can return arbitrary information.Now, the TCP connector returns a
Local<ClientAddr>
and the TLSconnector conditionally includes the negotiated protocol.
This change sets up the ability for the HTTP client to negotiate
protocol upgrading via ALPN instead of using per-request headers.
Changes are broken into distinct commits. No functional changes.