fix: Don't flag remotes as un/healty as a result of authless requests

This would break the sender flush in the request auth handler since marking a server as healthy after it was already healthy makes `mark_healthy` return `false`, so the flush would never run.
This commit is contained in:
timedout committed 2026-12-04 12:35:07 +00:00
1 parent b305b765f1
commit d81f65c4aa
1 file changed
+18 -8
+18 -8
View File
@@ -149,7 +149,8 @@ impl super::Service {
// - Timeout (normal vs slow)
// and having a billion functions and conditions for all of those is not
// ideal.
if TypeId::of::<T::Authentication>() != TypeId::of::<NoAuthentication>() {
let doctor = TypeId::of::<T::Authentication>() != TypeId::of::<NoAuthentication>();
if doctor {
self.ensure_remote_is_healthy(dest)?;
}
@@ -175,7 +176,8 @@ impl super::Service {
self.validate_url(request.url())?;
self.services.server.check_running()?;
self.perform::<T>(dest, &actual, request, client).await
self.perform::<T>(dest, &actual, request, client, doctor)
.await
}
/// Actually sends the federation request, handling the response before
@@ -188,6 +190,7 @@ impl super::Service {
actual: &Resolution,
request: Request,
client: &Client,
doctor: bool,
) -> Result<T::IncomingResponse>
where
T: OutgoingRequest + Send,
@@ -223,8 +226,10 @@ impl super::Service {
.record(elapsed.as_secs_f64(), &[KeyValue::new("outcome", outcome)]);
match response {
| Ok(response) =>
self.handle_response::<T>(dest, actual, &method, &url, response)
self.handle_response::<T>(dest, actual, &method, &url, response, doctor)
.await,
| Err(error) if !doctor =>
Err(handle_error(actual, &method, &url, error).expect_err("always returns error")),
| Err(error) => {
// This awful wrapping hack is required because `reqwest::Error`
// does not implement `Clone`, but we need to convert it
@@ -270,6 +275,7 @@ impl super::Service {
method: &Method,
url: &Url,
response: Response,
doctor: bool,
) -> Result<T::IncomingResponse>
where
T: OutgoingRequest + Send,
@@ -298,13 +304,17 @@ impl super::Service {
body.as_ref(),
))
.inspect(|_| {
self.mark_healthy(dest);
if doctor {
self.mark_healthy(dest);
}
})
.map_err(|e| {
// Bad 200 response is usually a sign of bad routing, so we'll mark
// as stale. We won't mark as offline though since we technically
// got a response.
self.mark_destination_stale(dest);
if doctor {
// Bad 200 response is usually a sign of bad routing, so we'll
// mark as stale. We won't mark as offline though since we
// technically got a response.
self.mark_destination_stale(dest);
}
err!(BadServerResponse("Server returned bad 200 response: {e:?}"))
})
}