Skip to content

Commit 1f0b968

Browse files
authored
Represent local identity as an Option (#836)
There's only one reason we may lack a local identity: when it's explicitly disabled. This change decouples the local identity types from the `ReasonForNoPeerName` conditional, as local identity has nothing to do with peer names. We instead represent local identity as a simple `Option` type.
1 parent e0271b4 commit 1f0b968

File tree

17 files changed

+44
-51
lines changed

17 files changed

+44
-51
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,7 @@ dependencies = [
682682
"linkerd-exp-backoff",
683683
"linkerd-http-classify",
684684
"linkerd-http-metrics",
685+
"linkerd-identity",
685686
"linkerd-metrics",
686687
"linkerd-opencensus",
687688
"linkerd-proxy-api-resolve",

linkerd/app/core/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ linkerd-error-respond = { path = "../../error-respond" }
3838
linkerd-exp-backoff = { path = "../../exp-backoff" }
3939
linkerd-http-classify = { path = "../../http-classify" }
4040
linkerd-http-metrics = { path = "../../http-metrics" }
41+
linkerd-identity = { path = "../../identity" }
4142
linkerd-metrics = { path = "../../metrics" }
4243
linkerd-transport-header = { path = "../../transport-header" }
4344
linkerd-opencensus = { path = "../../opencensus" }

linkerd/app/core/src/control.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Config {
4545
self,
4646
dns: dns::Resolver,
4747
metrics: metrics::ControlHttp,
48-
identity: tls::Conditional<I>,
48+
identity: Option<I>,
4949
) -> Client<B>
5050
where
5151
B: http::HttpBody + Send + 'static,

linkerd/app/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub use linkerd_drain as drain;
1717
pub use linkerd_error::{Error, Never, Recover};
1818
pub use linkerd_exp_backoff as exp_backoff;
1919
pub use linkerd_http_metrics as http_metrics;
20+
pub use linkerd_identity as identity;
2021
pub use linkerd_opencensus as opencensus;
2122
pub use linkerd_reconnect as reconnect;
2223
pub use linkerd_service_profiles as profiles;

linkerd/app/gateway/src/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::make::MakeGateway;
22
use linkerd_app_core::{
3-
discovery_rejected, profiles, proxy::http, svc, transport::tls, Error, NameAddr, NameMatch,
3+
discovery_rejected, identity, profiles, proxy::http, svc, Error, NameAddr, NameMatch,
44
};
55
use linkerd_app_inbound::endpoint as inbound;
66
use linkerd_app_outbound as outbound;
@@ -19,7 +19,7 @@ impl Config {
1919
self,
2020
outbound: O,
2121
profiles: P,
22-
local_id: tls::PeerIdentity,
22+
local_id: Option<identity::Name>,
2323
) -> impl svc::NewService<
2424
inbound::Target,
2525
Service = impl tower::Service<

linkerd/app/gateway/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ mod test {
142142
Config { allow_discovery }.build(
143143
move |_: _| outbound.clone(),
144144
profiles,
145-
tls::PeerIdentity::Some(identity::Name::from(
145+
Some(identity::Name::from(
146146
dns::Name::from_str("gateway.id.test").unwrap(),
147147
)),
148148
)

linkerd/app/gateway/src/make.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
use super::gateway::Gateway;
2-
use linkerd_app_core::{profiles, svc, transport::tls, NameAddr};
2+
use linkerd_app_core::{identity, profiles, svc, transport::tls, NameAddr};
33
use linkerd_app_inbound::endpoint as inbound;
44
use linkerd_app_outbound as outbound;
55
use tracing::debug;
66

77
#[derive(Clone, Debug)]
88
pub(crate) struct MakeGateway<O> {
99
outbound: O,
10-
local_id: tls::PeerIdentity,
10+
local_id: Option<identity::Name>,
1111
}
1212

1313
impl<O> MakeGateway<O> {
14-
pub fn new(outbound: O, local_id: tls::PeerIdentity) -> Self {
14+
pub fn new(outbound: O, local_id: Option<identity::Name>) -> Self {
1515
Self { outbound, local_id }
1616
}
1717
}
@@ -33,7 +33,7 @@ where
3333
} = target;
3434

3535
let (source_id, local_id) = match (tls_client_id, self.local_id.clone()) {
36-
(tls::Conditional::Some(src), tls::Conditional::Some(local)) => (src, local),
36+
(tls::Conditional::Some(src), Some(local)) => (src, local),
3737
_ => return Gateway::NoIdentity,
3838
};
3939

linkerd/app/inbound/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl Config {
7878
pub fn build<I, C, L, LSvc, P>(
7979
self,
8080
listen_addr: SocketAddr,
81-
local_identity: tls::Conditional<identity::Local>,
81+
local_identity: Option<identity::Local>,
8282
connect: C,
8383
http_loopback: L,
8484
profiles_client: P,
@@ -386,7 +386,7 @@ impl Config {
386386
self,
387387
detect: D,
388388
tcp_forward: F,
389-
identity: tls::Conditional<identity::Local>,
389+
identity: Option<identity::Local>,
390390
metrics: metrics::Proxy,
391391
) -> impl svc::NewService<
392392
listen::Addrs,

linkerd/app/outbound/src/tcp/connect.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use tracing::debug_span;
1515
pub fn stack<P>(
1616
config: &ConnectConfig,
1717
server_port: u16,
18-
local_identity: tls::Conditional<identity::Local>,
18+
local_identity: Option<identity::Local>,
1919
metrics: &metrics::Proxy,
2020
) -> impl svc::Service<
2121
Endpoint<P>,

linkerd/app/src/admin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::identity::LocalIdentity;
1+
use crate::identity;
22
use linkerd_app_core::{
33
admin, config::ServerConfig, drain, metrics::FmtMetrics, serve, trace, transport::tls, Error,
44
};
@@ -20,7 +20,7 @@ pub struct Admin {
2020
impl Config {
2121
pub fn build<R>(
2222
self,
23-
identity: LocalIdentity,
23+
identity: Option<identity::Local>,
2424
report: R,
2525
trace: trace::Handle,
2626
drain: drain::Watch,

0 commit comments

Comments
 (0)