Update profile response to include a logical address#954
Conversation
ebf67d6 moved endpoint construction logic out of the logical stacks. In doing so, the gateway was incorrectly configured to mark endpoints with disabled identity, preventing mTLS between the gateway and destination service. This change moves endpoint construction into each logical stack so that it need not be configured on each instantiation.
In order to make the server and logical stack more flexible, we need to make stacks generic over their input target type. This change modifies the innermost `tcp::connect` stack to not depend on a concrete target type, instead relying on `Param` constraints. A new `tcp::Connect` target type is introduced to be constructed by the TCP connect stack.
THe HTTP endpoint stack is coupled to the Endpoint target type. In order to make the outbound stack more flexible so that the endpoint stack can be used without the logical stack, this change updates the outbound HTTP endpoint stack to be generic over its target type.
The HTTP server stack is unnecessarily bound to a target type. In order to support more flexible stack composition, this change makes the outbound HTTP server stack generic over its target type.
Profile responses optionally include a service name, but we only ever use it in the context of an address (i.e. with a port). This change introduces a `profiles::LookupAddr` param type that is used as input into the profile client -- the lookup address may hold either a named or numbered address. Service profile responses now include a `LogicalAddr` that must be a named address. This sets up for requiring that concrete addresses are named.
hawkw
left a comment
There was a problem hiding this comment.
overall, this looks good to me! the change is actually much more straightforward than it seems from the changed lines count; it just touches a lot of files.
i did wonder if it makes sense to get rid of the type parameter on GetProfile, but that could also happen separately.
| io::AsyncRead + io::AsyncWrite + tls::HasNegotiatedProtocol + Send + Unpin + 'static, | ||
| O::Future: Send + Unpin + 'static, | ||
| P: profiles::GetProfile<profiles::LogicalAddr> + Clone + Send + Sync + Unpin + 'static, | ||
| P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + Unpin + 'static, |
There was a problem hiding this comment.
AFAICT, there are now no impls of GetProfile for anything other than a LookupAddr:
:# eliza on butterfly in linkerd2-proxy on ver/profile-addr [$?] via ⚙️ v1.49.0
:; rg "GetProfile<"
linkerd/service-profiles/src/default.rs
25: S: GetProfile<T>,
linkerd/service-profiles/src/discover.rs
14: G: GetProfile<F::Request> + Clone,
34: G: GetProfile<T>,
linkerd/service-profiles/src/lib.rs
54:pub trait GetProfile<T> {
68:impl<T, S> GetProfile<T> for S
84: P: GetProfile<T>,
linkerd/app/outbound/src/discover.rs
28: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + 'static,
linkerd/app/outbound/src/lib.rs
113: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + 'static,
141: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + Unpin + 'static,
linkerd/app/outbound/src/ingress.rs
44: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + Unpin + 'static,
linkerd/app/gateway/src/lib.rs
87: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + Unpin + 'static,
linkerd/app/inbound/src/lib.rs
138: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + 'static,
228: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + 'static,
linkerd/app/inbound/src/http/mod.rs
118: P: profiles::GetProfile<profiles::LookupAddr> + Clone + Send + Sync + 'static,
Should we maybe just remove the type parameter and change GetProfile to
pub trait GetProfile {
type Error: Into<Error>;
type Future: Future<Output = Result<Option<Receiver>, Self::Error>>;
fn get_profile(&mut self, target: LookupAddr) -> Self::Future;
}or am I missing something?
There was a problem hiding this comment.
seems like a fine change but it will touch more than this pr needs to.
There was a problem hiding this comment.
👍 i can throw together a PR after this lands
| impl fmt::Display for LookupAddr { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| self.0.fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl FromStr for LookupAddr { | ||
| type Err = <Addr as FromStr>::Err; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| Addr::from_str(s).map(LookupAddr) | ||
| } | ||
| } | ||
|
|
||
| impl From<Addr> for LookupAddr { | ||
| fn from(a: Addr) -> Self { | ||
| Self(a) | ||
| } | ||
| } | ||
|
|
||
| impl Into<Addr> for LookupAddr { | ||
| fn into(self) -> Addr { | ||
| self.0 | ||
| } | ||
| } | ||
|
|
||
| // === impl LogicalAddr === | ||
|
|
||
| impl fmt::Display for LogicalAddr { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| self.0.fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl FromStr for LogicalAddr { | ||
| type Err = <NameAddr as FromStr>::Err; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| NameAddr::from_str(s).map(LogicalAddr) | ||
| } | ||
| } | ||
|
|
||
| impl From<NameAddr> for LogicalAddr { | ||
| fn from(na: NameAddr) -> Self { | ||
| Self(na) | ||
| } | ||
| } | ||
|
|
||
| impl Into<NameAddr> for LogicalAddr { | ||
| fn into(self) -> NameAddr { | ||
| self.0 | ||
| } | ||
| } |
There was a problem hiding this comment.
some of these trivial impls can probably be #[inline], though I'm not sure if it it actually matters; i just noticed we added the attribute on other code in this PR...
| #[derive(Clone, Debug, Hash, Eq, PartialEq)] | ||
| pub struct LookupAddr(pub Addr); | ||
|
|
||
| /// A bound logical service address |
There was a problem hiding this comment.
nit: should the comment maybe make it clearer that this is part of the profile returned by a lookup, in contrast to LookupAddr, which is the input?
| impl fmt::Display for LookupAddr { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| self.0.fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl FromStr for LookupAddr { | ||
| type Err = <Addr as FromStr>::Err; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| Addr::from_str(s).map(LookupAddr) | ||
| } | ||
| } | ||
|
|
||
| impl From<Addr> for LookupAddr { | ||
| fn from(a: Addr) -> Self { | ||
| Self(a) | ||
| } | ||
| } | ||
|
|
||
| impl Into<Addr> for LookupAddr { | ||
| fn into(self) -> Addr { | ||
| self.0 | ||
| } | ||
| } | ||
|
|
||
| // === impl LogicalAddr === | ||
|
|
||
| impl fmt::Display for LogicalAddr { | ||
| fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
| self.0.fmt(f) | ||
| } | ||
| } | ||
|
|
||
| impl FromStr for LogicalAddr { | ||
| type Err = <NameAddr as FromStr>::Err; | ||
|
|
||
| fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
| NameAddr::from_str(s).map(LogicalAddr) | ||
| } | ||
| } | ||
|
|
||
| impl From<NameAddr> for LogicalAddr { | ||
| fn from(na: NameAddr) -> Self { | ||
| Self(na) | ||
| } | ||
| } | ||
|
|
||
| impl Into<NameAddr> for LogicalAddr { | ||
| fn into(self) -> NameAddr { | ||
| self.0 | ||
| } | ||
| } |
There was a problem hiding this comment.
a lot of these are pretty trivial, maybe they should be marked as #[inline]able? not sure if this matters at all, just noticed that we added the attribute elsewhere in this branch...
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960)
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960)
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960)
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960) Signed-off-by: Jijeesh <[email protected]>
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960)
This release fixes two issues: 1. The inbound proxy could break non-meshed TLS connections when the initial ClientHello message was larger than 512 bytes or when the entire message was not received in the first data packet of the connection. TLS detection has been fixed to ensure that the entire message is preserved in these cases. 2. The admin server could emit warnings about HTTP detection failing in some innocuous situations, such as when the socket closes before a request is sent. These situations are now handled gracefully without logging warnings. --- * Update MAINTAINERS to point at the main repo (linkerd/linkerd2-proxy#950) * outbound: Configure endpoint construction in logical stack (linkerd/linkerd2-proxy#949) * outbound: Decouple the TCP connect stack from the target type (linkerd/linkerd2-proxy#951) * outbound: Make HTTP endpoint stack generic on its target (linkerd/linkerd2-proxy#952) * outbound: Make the HTTP server stack generic (linkerd/linkerd2-proxy#953) * Update profile response to include a logical address (linkerd/linkerd2-proxy#954) * inbound, outbound: `Param`-ify `listen::Addrs` (linkerd/linkerd2-proxy#955) * tls: Fix inbound I/O when TLS detection fails (linkerd/linkerd2-proxy#958) * tls: Test SNI detection (linkerd/linkerd2-proxy#959) * admin: Handle connections that fail protocol detection (linkerd/linkerd2-proxy#960)
Profile responses optionally include a service name, but we only ever
use it in the context of an address (i.e. with a port).
This change introduces a
profiles::LookupAddrparam type that is usedas input into the profile client -- the lookup address may hold either a
named or numbered address. Service profile responses now include a
LogicalAddrthat must be a named address.This sets up for requiring that concrete addresses are named.