Skip to content

Make SkipDetect more generic as stack::MakeSwitch#657

Merged
olix0r merged 4 commits intomainfrom
ver/generic-skip-detect
Sep 16, 2020
Merged

Make SkipDetect more generic as stack::MakeSwitch#657
olix0r merged 4 commits intomainfrom
ver/generic-skip-detect

Conversation

@olix0r
Copy link
Member

@olix0r olix0r commented Sep 16, 2020

SkipDetect is needlessly coupled to its listen::Addrs target type and
the Accept stack's shape. In reality, it's pretty similar to the
fallback module, except that decisions are made on the target rather
than the response future.

This change replaces the core::proxy::skip_detct module with
stack::switch.

Above all, this allows us to use other targets with this module, which
is needed to do discovery before protoocl detection (and to use the
results of discovery to inform detection).

SkipDetect is needlessly coupled to its `listen::Addrs` target type and
the Accept stack's shape. In reality, it's pretty similar to the
fallback module, except that decisions are made on the target rather
than the response future.

This change replaces the `core::proxy::skip_detct` module with
`stack::switch`.

Above all, this allows us to use other targets with this module, which
is needed to do discovery before protoocl detection (and to use the
results of discovery to inform detection).
@olix0r olix0r requested a review from a team September 16, 2020 14:36
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 good to me, and the change is really quite simple...i had some dumb naming bikesheds, feel free to disregard them

@@ -0,0 +1,84 @@
//! A middleware that switches between two underlying stacks, depending on the
//! target type.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: it's really the target value, not the target type --- the type is the same for both stacks...

Comment on lines +9 to +16
/// Determines whether the primary stack should be used.
pub trait Switch<T> {
fn use_primary(&self, target: &T) -> bool;
}

/// Makes either the primary or fallback stack, as determined by an `S`-typed
/// `Switch`.
pub struct MakeSwitch<S, P, F> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some part of me wants to push harder on unifying terminology between this and the existing fallback stuff --- what we've really implemented here is sort of a FallbackOnTarget and FallbackOnError. but, it doesn't super matter.

Comment on lines +9 to +16
/// Determines whether the primary stack should be used.
pub trait Switch<T> {
fn use_primary(&self, target: &T) -> bool;
}

/// Makes either the primary or fallback stack, as determined by an `S`-typed
/// `Switch`.
pub struct MakeSwitch<S, P, F> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not sold on calling this MakeSwitch, since it would work equally well at the Service/Request level as well as the MakeService/Target level...names starting with Make kinda suggest to me that this only ever has a Service response type. Maybe the service should be Switch and the trait `Predicate or something?

@olix0r
Copy link
Member Author

olix0r commented Sep 16, 2020

Can address naming in a followup, but want to get this merged

@olix0r olix0r merged commit 12011fb into main Sep 16, 2020
@olix0r olix0r deleted the ver/generic-skip-detect branch September 16, 2020 18:27
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Sep 18, 2020
This release fixes a recent regression in multicluster gateway
configurations that would forbid inbound gateway traffic. It also fixes
URI normalization for orig-proto-upgrade requests that do not include a
`Host` header.

---

* http: Simplify stacks and target types (linkerd/linkerd2-proxy#656)
* Make SkipDetect more generic as stack::MakeSwitch (linkerd/linkerd2-proxy#657)
* introduce tests for isolated services (linkerd/linkerd2-proxy#655)
* http: Put normalize_uri back on the stack (linkerd/linkerd2-proxy#659)
* inbound: Apply loop detection on the connect stack (linkerd/linkerd2-proxy#660)
* tracing: Elide redundant info in tracing contexts (linkerd/linkerd2-proxy#661)
* outbound: Reorganize outbound stacks (linkerd/linkerd2-proxy#662)
* app: Decouple stacks from listeners (linkerd/linkerd2-proxy#663)
* inbound: Split HTTP detection stack from TLS (linkerd/linkerd2-proxy#664)
* integration: Bundle tests in src (linkerd/linkerd2-proxy#665)
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Sep 19, 2020
This release fixes a recent regression in multicluster gateway
configurations that would forbid inbound gateway traffic. It also fixes
URI normalization for orig-proto-upgrade requests that do not include a
`Host` header.

---

* http: Simplify stacks and target types (linkerd/linkerd2-proxy#656)
* Make SkipDetect more generic as stack::MakeSwitch (linkerd/linkerd2-proxy#657)
* introduce tests for isolated services (linkerd/linkerd2-proxy#655)
* http: Put normalize_uri back on the stack (linkerd/linkerd2-proxy#659)
* inbound: Apply loop detection on the connect stack (linkerd/linkerd2-proxy#660)
* tracing: Elide redundant info in tracing contexts (linkerd/linkerd2-proxy#661)
* outbound: Reorganize outbound stacks (linkerd/linkerd2-proxy#662)
* app: Decouple stacks from listeners (linkerd/linkerd2-proxy#663)
* inbound: Split HTTP detection stack from TLS (linkerd/linkerd2-proxy#664)
* integration: Bundle tests in src (linkerd/linkerd2-proxy#665)
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