Skip to content

Commit e56bbec

Browse files
authored
outbound: Make discovery error detection generic (#644)
The outbound proxy handles discovery rejection error with a fallback router. The current implementation does not allow for middlewares to wrap errors in a general fashion. This change updates the `is_discovery_rejected` function to examine arbitrary error types to determine if the underlying error matches the known types.
1 parent b61af18 commit e56bbec

File tree

1 file changed

+7
-5
lines changed
  • linkerd/app/outbound/src

1 file changed

+7
-5
lines changed

linkerd/app/outbound/src/lib.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,13 @@ impl From<Error> for DiscoveryError {
594594
}
595595

596596
fn is_discovery_rejected(err: &Error) -> bool {
597-
tracing::trace!(?err, "is_discovery_rejected");
598-
599-
if let Some(e) = err.downcast_ref::<svc::buffer::error::ServiceError>() {
600-
return is_discovery_rejected(e.inner());
597+
fn is_rejected(err: &(dyn std::error::Error + 'static)) -> bool {
598+
err.is::<DiscoveryRejected>()
599+
|| err.is::<profiles::InvalidProfileAddr>()
600+
|| err.source().map(is_rejected).unwrap_or(false)
601601
}
602602

603-
err.is::<DiscoveryRejected>() || err.is::<profiles::InvalidProfileAddr>()
603+
let rejected = is_rejected(&**err);
604+
tracing::debug!(rejected, %err);
605+
rejected
604606
}

0 commit comments

Comments
 (0)