-
Notifications
You must be signed in to change notification settings - Fork 91
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
Refactor build_requests #1082
Refactor build_requests #1082
Conversation
Skipping CI for Draft Pull Request. |
b7eaf4e
to
7cc15e9
Compare
8efb13b
to
c59d4ae
Compare
264555a
to
f49d153
Compare
let result_tracker = Box::new(ConnectionResult::new( | ||
source_addr, | ||
req.gateway, | ||
req.actual_destination, |
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.
👍
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.
LGTM, mostly nits, will put a hold which you can self-remove.
@@ -329,6 +278,14 @@ impl OutboundConnection { | |||
.body(()) | |||
.expect("builder with known status code should not fail"); | |||
|
|||
let pool_key = Box::new(pool::WorkloadKey { | |||
src_id: req.source.identity(), | |||
// Clone here shouldn't be needed ideally, we could just take ownership of Request. |
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.
Yeah - why construct the poolkey here at all? We can just chuck the whole Box<request>
+ remote_addr at send_request_pooled
?.
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.
We have the same clone problem either way I think (actually, maybe not since we Box::pin the future).
If we pass owned Request
here we can easy deconstruct the request and not clone upstream_sans
. But then we end up paying for the stack cost of Request twice (and I think it somehow actually becomes 4x due to some async stuff?). If we have a reference we don't need to, but then we need to clone this. If we kick this down further into send_request_pooled
we have the same problem, just possibly more stack usage I think?
I guess maybe an owned Box<Request>
wouldn't have that problem...
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.
I guess maybe an owned Box wouldn't have that problem...
That would be my intuition, but IDK for sure. Eh, it's a small thing either way.
src/proxy/outbound.rs
Outdated
{ | ||
let upstream_sans = waypoint.workload_and_services_san(); | ||
let actual_destination = waypoint.workload_socket_addr(); | ||
trace!("built request to service waypoint proxy"); |
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.
trace!("built request to service waypoint proxy"); | |
debug!("built request to service waypoint proxy"); |
Mega nit: slight pref for logs indicating request processing decisions to be debug!
- trace is a lot of noise.
src/proxy/outbound.rs
Outdated
} | ||
.await? | ||
else { | ||
trace!("built request as passthrough; no upstream found"); |
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.
ditto nit
// The identity we will assert for the next hop; this may not be the same as destination_workload | ||
// Source workload sending the request | ||
source: Arc<Workload>, | ||
// The actual destination workload we are targeting. When proxying through a waypoint, this is the waypoint, |
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.
👍 for the comments/naming here, extreme obviousness is good.
&self, | ||
network: Strng, | ||
source_workload: &Workload, | ||
addr: SocketAddr, | ||
) -> Option<Upstream> { | ||
) -> Option<(Arc<Workload>, u16, Option<Arc<Service>>)> { |
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.
nit: maybe type
this (FoundUpstream
)?
4858ef3
to
0351fbe
Compare
0351fbe
to
a374db6
Compare
In response to a cherrypick label: #1082 failed to apply on top of branch "release-1.22":
|
In response to a cherrypick label: new issue created for failed cherrypick: #1087 |
Fixes #846
Fixes #1009
This does a general cleanup of a lot of accumulated cruft. Lots of minor changes, but main ones:
Request
andpstream
type: rename fields to make it clear what are attributes of original workload/waypoint/network gatways. No more "gateway_address", especially not the mutable aspectState
has metrics now so we don't need to pass it in most functions