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

outbound: Add a policy router #2251

Merged
merged 45 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e9bd66b
outbound: Decouple outbound HTTP server from logical target
olix0r Feb 18, 2023
3b8dae0
outbound: Introduce a new outbound-route watch type
olix0r Feb 19, 2023
403e511
outbound: Add a policy router
olix0r Feb 20, 2023
b15d94f
Add gRPC route support
olix0r Feb 20, 2023
21ba655
comments
olix0r Feb 20, 2023
800d6e6
fixyad
olix0r Feb 20, 2023
b75ba15
golf
olix0r Feb 20, 2023
fa25d11
golf+
olix0r Feb 20, 2023
15228ef
-dead_code
olix0r Feb 20, 2023
96ad268
comments
olix0r Feb 20, 2023
6ca5e5e
fixup
olix0r Feb 20, 2023
4c69fde
fixup
olix0r Feb 20, 2023
7b0bc8e
golf
olix0r Feb 20, 2023
b2fa93c
Merge branch 'main' into ver/watch-routes
olix0r Feb 20, 2023
f0759ef
fixup
olix0r Feb 20, 2023
69f6eb1
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 20, 2023
8c63ade
simplify policy router with union types
olix0r Feb 20, 2023
cca695d
-checks
olix0r Feb 20, 2023
da52c5b
golf
olix0r Feb 20, 2023
9719b72
back out unneeded change
olix0r Feb 20, 2023
67c9b69
comments/consistency
olix0r Feb 20, 2023
b7a42c5
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 20, 2023
1b8c812
Simplify type names/reexports
olix0r Feb 20, 2023
429509e
Add simple header-based routing test
olix0r Feb 20, 2023
fd04961
Simplify type names/reexports
olix0r Feb 20, 2023
c05ad35
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 20, 2023
25bf672
simplify config builder with helper functions
olix0r Feb 20, 2023
9f69089
more golf
olix0r Feb 20, 2023
e753d42
more setup
olix0r Feb 20, 2023
c8199e3
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 20, 2023
6e7aef5
cleanup
olix0r Feb 20, 2023
8527553
test yak
olix0r Feb 21, 2023
8de2f6f
hang layers off of their param types for clarity
olix0r Feb 21, 2023
950dbf8
more organization
olix0r Feb 21, 2023
9f9b42f
forward-port cleanup
olix0r Feb 21, 2023
b0e6211
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 21, 2023
9a6e2a1
Merge branch 'main' into ver/watch-routes
olix0r Feb 21, 2023
339208c
hang profile layers off param types
olix0r Feb 21, 2023
3694c38
Merge branch 'ver/watch-routes' into ver/outbound-policy-router
olix0r Feb 21, 2023
3d3ca80
test yaks
olix0r Feb 21, 2023
218d8f6
Fix new test
olix0r Feb 21, 2023
658d030
Merge branch 'main' into ver/outbound-policy-router
olix0r Feb 22, 2023
f6e4d1e
test yak
olix0r Feb 22, 2023
cdbf023
Preserve match details in route targets
olix0r Feb 22, 2023
0235d66
fixup comments
olix0r Feb 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -945,10 +945,12 @@ dependencies = [
"linkerd-distribute",
"linkerd-http-classify",
"linkerd-http-retry",
"linkerd-http-route",
"linkerd-identity",
"linkerd-io",
"linkerd-meshtls",
"linkerd-meshtls-rustls",
"linkerd-proxy-client-policy",
"linkerd-retry",
"linkerd-tracing",
"parking_lot",
Expand Down
6 changes: 4 additions & 2 deletions linkerd/app/outbound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ Configures and runs the outbound proxy
"""

[features]
test-util = ["linkerd-app-test", "linkerd-meshtls-rustls/test-util"]

default = []
allow-loopback = []
test-subscriber = []
test-util = ["linkerd-app-test", "linkerd-meshtls-rustls/test-util"]

[dependencies]
bytes = "1"
http = "0.2"
Expand All @@ -24,8 +24,10 @@ linkerd-app-test = { path = "../test", optional = true }
linkerd-distribute = { path = "../../distribute" }
linkerd-http-classify = { path = "../../http-classify" }
linkerd-http-retry = { path = "../../http-retry" }
linkerd-http-route = { path = "../../http-route" }
linkerd-identity = { path = "../../identity" }
linkerd-meshtls-rustls = { path = "../../meshtls/rustls", optional = true }
linkerd-proxy-client-policy = { path = "../../proxy/client-policy" }
linkerd-retry = { path = "../../retry" }
parking_lot = "0.12"
thiserror = "1"
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/src/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod retry;
mod server;
mod strip_proxy_error;

pub use self::logical::{profile, LogicalAddr, Routes};
pub use self::logical::{policy, profile, LogicalAddr, Routes};
pub(crate) use self::require_id_header::IdentityRequired;
pub use linkerd_app_core::proxy::http::{self as http, *};

Expand Down
19 changes: 17 additions & 2 deletions linkerd/app/outbound/src/http/logical.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use linkerd_distribute as distribute;
use std::{fmt::Debug, hash::Hash};
use tokio::sync::watch;

pub mod policy;
pub mod profile;

/// Indicates the address used for logical routing.
Expand All @@ -22,6 +23,9 @@ pub struct LogicalAddr(pub Addr);
/// Configures the flavor of HTTP routing.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Routes {
/// Policy routes.
Policy(policy::Routes),

/// Service profile routes.
Profile(profile::Routes),

Expand Down Expand Up @@ -51,6 +55,8 @@ pub struct LogicalError {

#[derive(Clone, Debug, PartialEq, Eq)]
enum RouterParams<T: Clone + Debug + Eq + Hash> {
Policy(policy::Params<T>),

Profile(profile::Params<T>),

// TODO(ver) Remove this variant when policy routes are fully wired up.
Expand Down Expand Up @@ -155,6 +161,7 @@ where
S::Future: Send,
{
svc::layer::mk(move |concrete: N| {
let policy = svc::stack(concrete.clone()).push(policy::Params::layer());
let profile =
svc::stack(concrete.clone()).push(profile::Params::layer(metrics.clone()));
svc::stack(concrete)
Expand All @@ -168,10 +175,16 @@ where
parent,
})
}
RouterParams::Profile(profile) => svc::Either::B(profile),
RouterParams::Profile(profile) => {
svc::Either::B(svc::Either::A(profile))
}
RouterParams::Policy(policy) => svc::Either::B(svc::Either::B(policy)),
})
},
profile.into_inner(),
// Switch profile and policy routing.
profile
.push_switch(Ok::<_, Infallible>, policy.into_inner())
.into_inner(),
)
.push(svc::NewMapErr::layer_from_target::<LogicalError, _>())
.push_on_service(svc::MapErr::layer_boxed())
Expand All @@ -187,6 +200,7 @@ where
{
fn from((routes, parent): (Routes, T)) -> Self {
match routes {
Routes::Policy(routes) => Self::Policy((routes, parent).into()),
Routes::Profile(routes) => Self::Profile((routes, parent).into()),
Routes::Endpoint(addr, metadata) => Self::Endpoint(addr, metadata, parent),
}
Expand All @@ -199,6 +213,7 @@ where
{
fn param(&self) -> LogicalAddr {
match self {
Self::Policy(ref p) => p.param(),
Self::Profile(ref p) => {
let profile::LogicalAddr(addr) = p.param();
LogicalAddr(addr.into())
Expand Down
Loading