Skip to content

Commit 610d5d5

Browse files
committed
fix(outbound): fix clientpolicy not work after remvoe service profile
This is a preview PR for linkerd/linkerd2#14274. In linkerd/idle-cache/src/lib.rs get_or_insert_with function, seems the sidercar with service profile and sidercar with client policy has the same key, which cause the cache didn't expire after we delete serviceprofile and create the new httproute for the target sevice for pods that keep requesting the target service. this pr try to create different keys for service profile httpsidecar and client policy httpsidecar Signed-off-by: wgjak47 <[email protected]>
1 parent 10643b9 commit 610d5d5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

linkerd/app/outbound/src/sidecar.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ struct HttpSidecar {
3030
orig_dst: OrigDstAddr,
3131
version: http::Variant,
3232
routes: watch::Receiver<http::Routes>,
33+
provider: RouteProvider,
3334
}
3435

3536
#[derive(Clone, Debug)]
@@ -44,6 +45,21 @@ struct OpaqSidecar {
4445
routes: watch::Receiver<opaq::Routes>,
4546
}
4647

48+
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
49+
pub enum RouteProvider {
50+
ServiceProfile,
51+
ClientPolicy,
52+
}
53+
54+
impl std::fmt::Debug for RouteProvider {
55+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56+
match self {
57+
Self::ServiceProfile => write!(f, "ServiceProfile"),
58+
Self::ClientPolicy => write!(f, "ClientPolicy"),
59+
}
60+
}
61+
}
62+
4763
// === impl Outbound ===
4864

4965
impl Outbound<()> {
@@ -196,10 +212,12 @@ impl From<protocol::Http<Sidecar>> for HttpSidecar {
196212
http::spawn_routes(profile, init, move |profile: &profiles::Profile| {
197213
Some(Self::mk_profile_routes(addr.clone(), profile))
198214
});
215+
let provider = RouteProvider::ServiceProfile;
199216
return HttpSidecar {
200217
orig_dst,
201218
version,
202219
routes,
220+
provider,
203221
};
204222
}
205223
}
@@ -210,10 +228,12 @@ impl From<protocol::Http<Sidecar>> for HttpSidecar {
210228
let routes = http::spawn_routes(policy, init, move |policy: &policy::ClientPolicy| {
211229
Self::mk_policy_routes(orig_dst, version, policy)
212230
});
231+
let provider = RouteProvider::ClientPolicy;
213232
HttpSidecar {
214233
orig_dst,
215234
version,
216235
routes,
236+
provider,
217237
}
218238
}
219239
}
@@ -334,6 +354,7 @@ impl std::hash::Hash for HttpSidecar {
334354
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
335355
self.orig_dst.hash(state);
336356
self.version.hash(state);
357+
self.provider.hash(state);
337358
}
338359
}
339360

0 commit comments

Comments
 (0)