Skip to content
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

Merged
merged 14 commits into from
Jan 3, 2022
Merged

Conversation

olix0r
Copy link
Member

@olix0r olix0r commented Jan 2, 2022

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.


Changes are broken into distinct commits. No functional changes.

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.
@olix0r olix0r requested a review from a team January 2, 2022 22:58
Copy link
Contributor

@hawkw hawkw left a 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! :)

linkerd/app/outbound/src/endpoint.rs Outdated Show resolved Hide resolved
linkerd/app/outbound/src/tcp/connect.rs Outdated Show resolved Hide resolved
linkerd/meshtls/src/client.rs Show resolved Hide resolved
linkerd/proxy/http/src/glue.rs Outdated Show resolved Hide resolved
Comment on lines +40 to +42
let local_addr = io.local_addr()?;
debug!(
local.addr = %io.local_addr().expect("cannot load local addr"),
local.addr = %local_addr,
Copy link
Contributor

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?

Copy link
Member Author

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.

linkerd/stack/src/connect.rs Outdated Show resolved Hide resolved
linkerd/stack/src/connect.rs Outdated Show resolved Hide resolved
linkerd/stack/src/connect.rs Outdated Show resolved Hide resolved
linkerd/tls/src/client.rs Outdated Show resolved Hide resolved
@olix0r olix0r merged commit f1df316 into main Jan 3, 2022
@olix0r olix0r deleted the ver/make-conn branch January 3, 2022 21:13
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jan 6, 2022
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)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Jan 6, 2022
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants