Skip to content

Commit 7a085ea

Browse files
committed
misc cleanup
1 parent de41d02 commit 7a085ea

File tree

3 files changed

+18
-26
lines changed

3 files changed

+18
-26
lines changed

linkerd/app/admin/src/stack.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ struct Rescue;
6969
// === impl Config ===
7070

7171
impl Config {
72+
/// Builds the admin endpoint server.
73+
///
74+
/// This method is asynchronous, as it must discover a `ServerPolicy` for
75+
/// the admin port.
7276
#[allow(clippy::too_many_arguments)]
73-
pub fn build<B, R, P>(
77+
pub async fn build<B, R, P>(
7478
self,
7579
bind: B,
76-
policy: P,
80+
policy: &P,
7781
identity: identity::Server,
7882
report: R,
7983
metrics: inbound::Metrics,
@@ -91,16 +95,11 @@ impl Config {
9195
let (listen_addr, listen) = bind.bind(&self.server)?;
9296

9397
let (ready, latch) = crate::server::Readiness::new();
94-
let serve = Box::pin(async move {
95-
// Get the policy for the admin server.
96-
// TODO(eliza): don't expect this...
97-
let policy = policy
98-
.get_policy(OrigDstAddr(listen_addr.into()))
99-
.await
100-
.expect("must be able to get policy for admin server");
101-
102-
let admin = crate::server::Admin::new(report, ready, shutdown, trace);
103-
let admin = svc::stack(move |_| admin.clone())
98+
// Get the policy for the admin server.
99+
let policy = policy.get_policy(OrigDstAddr(listen_addr.into())).await?;
100+
101+
let admin = crate::server::Admin::new(report, ready, shutdown, trace);
102+
let admin = svc::stack(move |_| admin.clone())
104103
.push(metrics.proxy.http_endpoint.to_layer::<classify::Response, _, Permitted>())
105104
.push_map_target(|(permit, http)| Permitted { permit, http })
106105
.push(inbound::policy::NewHttpPolicy::layer(metrics.http_authz.clone()))
@@ -164,8 +163,7 @@ impl Config {
164163
identity,
165164
}))
166165
.into_inner();
167-
serve::serve(listen, admin, drain.signaled()).await
168-
});
166+
let serve = Box::pin(serve::serve(listen, admin, drain.signaled()));
169167
Ok(Task {
170168
listen_addr,
171169
latch,

linkerd/app/inbound/src/policy.rs

-7
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ pub trait GetPolicy {
4646
type Future: Future<Output = Result<AllowPolicy, Error>>;
4747

4848
fn get_policy(&self, target: OrigDstAddr) -> Self::Future;
49-
50-
// fn into_service(self) -> GetPolicyService<Self>
51-
// where
52-
// Self: Sized,
53-
// {
54-
// GetPolicyService(self)
55-
// }
5649
}
5750

5851
#[derive(Clone, Debug, PartialEq, Eq)]

linkerd/app/src/lib.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -170,23 +170,24 @@ impl Config {
170170
let admin = {
171171
let identity = identity.receiver().server();
172172
let metrics = inbound.metrics();
173-
let policy = inbound_policies.clone();
174173
let report = inbound
175174
.metrics()
176175
.and_report(outbound.metrics())
177176
.and_report(report);
178-
info_span!("admin").in_scope(move || {
179-
admin.build(
177+
178+
admin
179+
.build(
180180
bind_admin,
181-
policy,
181+
&inbound_policies,
182182
identity,
183183
report,
184184
metrics,
185185
log_level,
186186
drain_rx,
187187
shutdown_tx,
188188
)
189-
})?
189+
.instrument(info_span!("admin"))
190+
.await?
190191
};
191192

192193
let dst_addr = dst.addr.clone();

0 commit comments

Comments
 (0)