Skip to content

Conversation

@olix0r
Copy link
Member

@olix0r olix0r commented Jan 28, 2023

The current discovery module resolves profiles from the control plane
and injects the response into the inner stack. So, in order to cache
this result, the entire stack must be cached. This prevents us from
interacting with discovery in any stack that includes
higher-cardinality, peer-specific metadata. This limitation is
unnecessary and cumbersome to work around.

This change adds an app::core::NewCachedDiscover module that
internally manages resolutions independently of the proxy stack.

This change does not remove any other existing caches, though it's
expected that several of these caches are no longer necessary.

Depends on #2196

olix0r and others added 17 commits January 27, 2023 18:51
Document incompatible backpressure behavior.
While most of our data-path queues need some sort of failfast behavior,
the queues used to request & synchronize discovery information do not
need to enforce timeouts locally.

This change updates the `stack::queue` module to support two variants
(via type aliases and builders): _with_ and _without_ timeouts.

This change introduces new param types for capacity and timeout
configuration. The `QueueConfig` type is moved back into the
`app::core::config` module. Furthermore, all config field names are
updated to replace "buffer" with "queue".
@olix0r olix0r changed the base branch from main to ver/foreverq January 29, 2023 03:37
olix0r added a commit that referenced this pull request Jan 29, 2023
In its normal sidecar configuration, the outbound stack does discovery
for each target ip:port. The result of this discovery will influences
protocol detection, etc.

In the gateway configuration, however, discovery is pushed into each
distinct stack so that lookups for HTTP services are deferred until
we've terminated the connection and wired it into the per-request
outbound stack.

This difference was primarily motivated by a limitation of the way that
discovery information is cached: because the outermost target includes
per-client metadata, we can't cache a discovery stack based on that
target type. #2195 removes this limitation so that we can update the
gateway stack to look more like a typical outbound stack (which will
allow for easier code reuse as new discovery types are introduced).

This change:

1. Splits the gateway stack into smaller functions for readability.
2. Extracts discovery from the HTTP and opaque stacks.
3. Renames gateway types for clarity.
olix0r added a commit that referenced this pull request Jan 29, 2023
In its normal sidecar configuration, the outbound stack does discovery
for each target ip:port. The result of this discovery will influences
protocol detection, etc.

In the gateway configuration, however, discovery is pushed into each
distinct stack so that lookups for HTTP services are deferred until
we've terminated the connection and wired it into the per-request
outbound stack.

This difference was primarily motivated by a limitation of the way that
discovery information is cached: because the outermost target includes
per-client metadata, we can't cache a discovery stack based on that
target type. #2195 removes this limitation so that we can update the
gateway stack to look more like a typical outbound stack (which will
allow for easier code reuse as new discovery types are introduced).

This change:

1. Splits the gateway stack into smaller functions for readability.
2. Extracts discovery from the HTTP and opaque stacks.
3. Renames gateway types for clarity.
The current discovery module resolves profiles from the control plane
and injects the response into the inner stack. So, in order to cache
this result, the entire stack must be cached. This prevents us from
interacting with discovery in any stack that includes
higher-cardinality, peer-specific metadata. This limitation is
unnecessary and cumbersome to work around.

This change adds an `app::core::NewCachedDiscover` module that
internally manages resolutions independently of the proxy stack.

This change does **not** remove any other existing caches, though it's
expected that several of these caches are no longer necessary.
@olix0r olix0r changed the title Ver/disco cache 2 Support caching discovery results independently of proxy stacks Jan 29, 2023
@olix0r olix0r self-assigned this Jan 30, 2023
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 --- we talked through most of the details offline, so this isn't a particularly lengthy review.

i'm still a little bit iffy of having every connection go through the queue even once the discovery watch has started, but i don't see any major problems with it. clever use of existing primitives here!

Base automatically changed from ver/foreverq to main January 30, 2023 20:30
@olix0r olix0r marked this pull request as ready for review January 30, 2023 20:51
@olix0r olix0r requested a review from a team as a code owner January 30, 2023 20:51
@olix0r olix0r changed the title Support caching discovery results independently of proxy stacks Cache discovery results independently of proxy stacks Jan 30, 2023
@olix0r olix0r merged commit 57df368 into main Jan 30, 2023
@olix0r olix0r deleted the ver/disco-cache-2 branch January 30, 2023 21:11
olix0r added a commit that referenced this pull request Jan 31, 2023
In its normal sidecar configuration, the outbound stack does discovery
for each target ip:port. The result of this discovery will influences
protocol detection, etc.

In the gateway configuration, however, discovery is pushed into each
distinct stack so that lookups for HTTP services are deferred until
we've terminated the connection and wired it into the per-request
outbound stack.

This difference was primarily motivated by a limitation of the way that
discovery information is cached: because the outermost target includes
per-client metadata, we can't cache a discovery stack based on that
target type. #2195 removes this limitation so that we can update the
gateway stack to look more like a typical outbound stack (which will
allow for easier code reuse as new discovery types are introduced).

This change:

1. Splits the gateway stack into smaller functions for readability.
2. Extracts discovery from the HTTP and opaque stacks.
3. Renames gateway types for clarity.
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Feb 16, 2023
This release includes many internal changes to prepare for the new
client policy API. Stack metric label values have changed to reflect the
new shape of the outbound proxy.

---

* build(deps): bump try-lock from 0.2.3 to 0.2.4 (linkerd/linkerd2-proxy#2139)
* build(deps): bump regex from 1.7.0 to 1.7.1 (linkerd/linkerd2-proxy#2145)
* build(deps): bump tokio from 1.24.0 to 1.24.1 (linkerd/linkerd2-proxy#2144)
* Parameterize the load balancer stack (linkerd/linkerd2-proxy#2142)
* build(deps): bump prost-types from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2147)
* build(deps): bump prost from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2148)
* build(deps): bump prost-build from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2149)
* stack: add `AnnotateError` middleware (linkerd/linkerd2-proxy#2158)
* Fix proxy-core dependencies (linkerd/linkerd2-proxy#2163)
* build(deps): bump tj-actions/changed-files from 35.3.1 to 35.4.1 (linkerd/linkerd2-proxy#2153)
* orig_proto: don't set `connection: close` on errors (linkerd/linkerd2-proxy#2171)
* build(deps): bump bumpalo from 3.11.1 to 3.12.0 (linkerd/linkerd2-proxy#2166)
* build(deps): bump proc-macro2 from 1.0.49 to 1.0.50 (linkerd/linkerd2-proxy#2165)
* build(deps): bump tj-actions/changed-files from 35.4.1 to 35.4.4 (linkerd/linkerd2-proxy#2172)
* build(deps): bump windows_x86_64_msvc from 0.42.0 to 0.42.1 (linkerd/linkerd2-proxy#2164)
* configure buffers from target `Param`s (linkerd/linkerd2-proxy#2173)
* Simplify profile discovery (linkerd/linkerd2-proxy#2170)
* stack: Unify AnnotateError and MapErr (linkerd/linkerd2-proxy#2180)
* build(deps): bump windows_aarch64_msvc from 0.42.0 to 0.42.1 (linkerd/linkerd2-proxy#2176)
* build(deps): bump async-trait from 0.1.61 to 0.1.63 (linkerd/linkerd2-proxy#2177)
* build(deps): bump tokio from 1.24.1 to 1.24.2 (linkerd/linkerd2-proxy#2178)
* Add the `meshtls-boring-fips` feature flag (linkerd/linkerd2-proxy#2168)
* Update HTTP error responder to log version info (linkerd/linkerd2-proxy#2182)
* build(deps): bump which from 4.3.0 to 4.4.0 (linkerd/linkerd2-proxy#2185)
* build(deps): bump derive_arbitrary from 1.2.2 to 1.2.3 (linkerd/linkerd2-proxy#2184)
* build(deps): bump unicode-bidi from 0.3.8 to 0.3.10 (linkerd/linkerd2-proxy#2183)
* build(deps): bump linkerd/dev from 38 to 39 (linkerd/linkerd2-proxy#2175)
* add target metadata to error contexts (linkerd/linkerd2-proxy#2162)
* build(deps): bump rustls from 0.20.7 to 0.20.8 (linkerd/linkerd2-proxy#2187)
* build(deps): bump ahash from 0.8.2 to 0.8.3 (linkerd/linkerd2-proxy#2188)
* build(deps): bump matches from 0.1.9 to 0.1.10 (linkerd/linkerd2-proxy#2189)
* Rename MakeThunk to NewThunk (linkerd/linkerd2-proxy#2197)
* Add `NewQueueWithoutTimeout` (linkerd/linkerd2-proxy#2196)
* Cache discovery results independently of proxy stacks  (linkerd/linkerd2-proxy#2195)
* core: Rename Stack utilities for clarity (linkerd/linkerd2-proxy#2199)
* gateway: Unify discovery for HTTP & opaque stacks (linkerd/linkerd2-proxy#2198)
* build(deps): bump libfuzzer-sys from 0.4.5 to 0.4.6 (linkerd/linkerd2-proxy#2193)
* build(deps): bump arbitrary from 1.2.2 to 1.2.3 (linkerd/linkerd2-proxy#2191)
* http: Remove `Clone` requirement in servers (linkerd/linkerd2-proxy#2200)
* build(deps): bump either from 1.8.0 to 1.8.1 (linkerd/linkerd2-proxy#2192)
* build(deps): bump bytes from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2202)
* build(deps): bump cc from 1.0.78 to 1.0.79 (linkerd/linkerd2-proxy#2203)
* build(deps): bump tj-actions/changed-files from 35.4.4 to 35.5.1 (linkerd/linkerd2-proxy#2211)
* build(deps): bump tokio from 1.24.2 to 1.25.0 (linkerd/linkerd2-proxy#2206)
* build(deps): bump miniz_oxide from 0.6.2 to 0.6.4 (linkerd/linkerd2-proxy#2207)
* build(deps): bump async-trait from 0.1.63 to 0.1.64 (linkerd/linkerd2-proxy#2205)
* Split outbound test modules into files (linkerd/linkerd2-proxy#2213)
* Disable broken tests (linkerd/linkerd2-proxy#2214)
* Add traceparent header parsing for w3c tracecontext (linkerd/linkerd2-proxy#2179)
* Simplify the `Resolve` trait alias (linkerd/linkerd2-proxy#2218)
* downgrade `miniz_oxide` from yanked 0.6.4 to 0.6.2 (linkerd/linkerd2-proxy#2219)
* build(deps): bump heck from 0.4.0 to 0.4.1 (linkerd/linkerd2-proxy#2215)
* ci: Fix check-each workflow (linkerd/linkerd2-proxy#2222)
* Use a cascading stack with protocol detection (linkerd/linkerd2-proxy#2221)
* ci: Fix quotation in list-crates (linkerd/linkerd2-proxy#2225)
* outbound: Split out separate 'opaq' modules (linkerd/linkerd2-proxy#2224)
* Update `linkerd2-proxy-api` to v0.8.0 (linkerd/linkerd2-proxy#2223)
* outbound: Lint stack target types (linkerd/linkerd2-proxy#2226)
* outbound: Split sidecar and ingress stack modules (linkerd/linkerd2-proxy#2227)
* gateway: Split 'http' and 'opaq' modules (linkerd/linkerd2-proxy#2230)
* test: Disable tap::rejects_incorrect_identity_when_identity_is_expected (linkerd/linkerd2-proxy#2231)
* outbound: Improve discovery cache test (linkerd/linkerd2-proxy#2233)
* integration: add destination update builders (linkerd/linkerd2-proxy#2232)
* Rename linkerd-server-policy to linkerd-proxy-server-policy (linkerd/linkerd2-proxy#2235)
* integration: add test for direct HTTP connections (linkerd/linkerd2-proxy#2234)
* outbound: Refactor stack target types (linkerd/linkerd2-proxy#2210)
* Add client-policy types (linkerd/linkerd2-proxy#2236)

Signed-off-by: Oliver Gould <[email protected]>
olix0r added a commit to linkerd/linkerd2 that referenced this pull request Feb 17, 2023
This release includes many internal changes to prepare for the new
client policy API. Stack metric label values have changed to reflect the
new shape of the outbound proxy.

This change also includes some test improvements that helped debug an
issue while merging this.

---

* build(deps): bump try-lock from 0.2.3 to 0.2.4 (linkerd/linkerd2-proxy#2139)
* build(deps): bump regex from 1.7.0 to 1.7.1 (linkerd/linkerd2-proxy#2145)
* build(deps): bump tokio from 1.24.0 to 1.24.1 (linkerd/linkerd2-proxy#2144)
* Parameterize the load balancer stack (linkerd/linkerd2-proxy#2142)
* build(deps): bump prost-types from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2147)
* build(deps): bump prost from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2148)
* build(deps): bump prost-build from 0.11.5 to 0.11.6 (linkerd/linkerd2-proxy#2149)
* stack: add `AnnotateError` middleware (linkerd/linkerd2-proxy#2158)
* Fix proxy-core dependencies (linkerd/linkerd2-proxy#2163)
* build(deps): bump tj-actions/changed-files from 35.3.1 to 35.4.1 (linkerd/linkerd2-proxy#2153)
* orig_proto: don't set `connection: close` on errors (linkerd/linkerd2-proxy#2171)
* build(deps): bump bumpalo from 3.11.1 to 3.12.0 (linkerd/linkerd2-proxy#2166)
* build(deps): bump proc-macro2 from 1.0.49 to 1.0.50 (linkerd/linkerd2-proxy#2165)
* build(deps): bump tj-actions/changed-files from 35.4.1 to 35.4.4 (linkerd/linkerd2-proxy#2172)
* build(deps): bump windows_x86_64_msvc from 0.42.0 to 0.42.1 (linkerd/linkerd2-proxy#2164)
* configure buffers from target `Param`s (linkerd/linkerd2-proxy#2173)
* Simplify profile discovery (linkerd/linkerd2-proxy#2170)
* stack: Unify AnnotateError and MapErr (linkerd/linkerd2-proxy#2180)
* build(deps): bump windows_aarch64_msvc from 0.42.0 to 0.42.1 (linkerd/linkerd2-proxy#2176)
* build(deps): bump async-trait from 0.1.61 to 0.1.63 (linkerd/linkerd2-proxy#2177)
* build(deps): bump tokio from 1.24.1 to 1.24.2 (linkerd/linkerd2-proxy#2178)
* Add the `meshtls-boring-fips` feature flag (linkerd/linkerd2-proxy#2168)
* Update HTTP error responder to log version info (linkerd/linkerd2-proxy#2182)
* build(deps): bump which from 4.3.0 to 4.4.0 (linkerd/linkerd2-proxy#2185)
* build(deps): bump derive_arbitrary from 1.2.2 to 1.2.3 (linkerd/linkerd2-proxy#2184)
* build(deps): bump unicode-bidi from 0.3.8 to 0.3.10 (linkerd/linkerd2-proxy#2183)
* build(deps): bump linkerd/dev from 38 to 39 (linkerd/linkerd2-proxy#2175)
* add target metadata to error contexts (linkerd/linkerd2-proxy#2162)
* build(deps): bump rustls from 0.20.7 to 0.20.8 (linkerd/linkerd2-proxy#2187)
* build(deps): bump ahash from 0.8.2 to 0.8.3 (linkerd/linkerd2-proxy#2188)
* build(deps): bump matches from 0.1.9 to 0.1.10 (linkerd/linkerd2-proxy#2189)
* Rename MakeThunk to NewThunk (linkerd/linkerd2-proxy#2197)
* Add `NewQueueWithoutTimeout` (linkerd/linkerd2-proxy#2196)
* Cache discovery results independently of proxy stacks  (linkerd/linkerd2-proxy#2195)
* core: Rename Stack utilities for clarity (linkerd/linkerd2-proxy#2199)
* gateway: Unify discovery for HTTP & opaque stacks (linkerd/linkerd2-proxy#2198)
* build(deps): bump libfuzzer-sys from 0.4.5 to 0.4.6 (linkerd/linkerd2-proxy#2193)
* build(deps): bump arbitrary from 1.2.2 to 1.2.3 (linkerd/linkerd2-proxy#2191)
* http: Remove `Clone` requirement in servers (linkerd/linkerd2-proxy#2200)
* build(deps): bump either from 1.8.0 to 1.8.1 (linkerd/linkerd2-proxy#2192)
* build(deps): bump bytes from 1.3.0 to 1.4.0 (linkerd/linkerd2-proxy#2202)
* build(deps): bump cc from 1.0.78 to 1.0.79 (linkerd/linkerd2-proxy#2203)
* build(deps): bump tj-actions/changed-files from 35.4.4 to 35.5.1 (linkerd/linkerd2-proxy#2211)
* build(deps): bump tokio from 1.24.2 to 1.25.0 (linkerd/linkerd2-proxy#2206)
* build(deps): bump miniz_oxide from 0.6.2 to 0.6.4 (linkerd/linkerd2-proxy#2207)
* build(deps): bump async-trait from 0.1.63 to 0.1.64 (linkerd/linkerd2-proxy#2205)
* Split outbound test modules into files (linkerd/linkerd2-proxy#2213)
* Disable broken tests (linkerd/linkerd2-proxy#2214)
* Add traceparent header parsing for w3c tracecontext (linkerd/linkerd2-proxy#2179)
* Simplify the `Resolve` trait alias (linkerd/linkerd2-proxy#2218)
* downgrade `miniz_oxide` from yanked 0.6.4 to 0.6.2 (linkerd/linkerd2-proxy#2219)
* build(deps): bump heck from 0.4.0 to 0.4.1 (linkerd/linkerd2-proxy#2215)
* ci: Fix check-each workflow (linkerd/linkerd2-proxy#2222)
* Use a cascading stack with protocol detection (linkerd/linkerd2-proxy#2221)
* ci: Fix quotation in list-crates (linkerd/linkerd2-proxy#2225)
* outbound: Split out separate 'opaq' modules (linkerd/linkerd2-proxy#2224)
* Update `linkerd2-proxy-api` to v0.8.0 (linkerd/linkerd2-proxy#2223)
* outbound: Lint stack target types (linkerd/linkerd2-proxy#2226)
* outbound: Split sidecar and ingress stack modules (linkerd/linkerd2-proxy#2227)
* gateway: Split 'http' and 'opaq' modules (linkerd/linkerd2-proxy#2230)
* test: Disable tap::rejects_incorrect_identity_when_identity_is_expected (linkerd/linkerd2-proxy#2231)
* outbound: Improve discovery cache test (linkerd/linkerd2-proxy#2233)
* integration: add destination update builders (linkerd/linkerd2-proxy#2232)
* Rename linkerd-server-policy to linkerd-proxy-server-policy (linkerd/linkerd2-proxy#2235)
* integration: add test for direct HTTP connections (linkerd/linkerd2-proxy#2234)
* outbound: Refactor stack target types (linkerd/linkerd2-proxy#2210)
* Add client-policy types (linkerd/linkerd2-proxy#2236)
@jeremychase jeremychase added this to the stable-2.13.0 milestone Mar 8, 2023
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.

4 participants