Skip to content

Commit

Permalink
ResponseError::DnsLookup for errors during DNS lookup (#1810)
Browse files Browse the repository at this point in the history
* Send only ResponseError::DnsLookup for all errors during DNS lookups

* Format

* CR
  • Loading branch information
infiniteregrets authored Aug 18, 2023
1 parent 3a14a73 commit ecff9f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.d/1809.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Send only ResponseError::DnsLookup for all errors during DNS lookups
16 changes: 13 additions & 3 deletions mirrord/agent/src/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::{

use mirrord_protocol::{
dns::{DnsLookup, GetAddrInfoRequest, GetAddrInfoResponse},
RemoteResult,
DnsLookupError, RemoteResult, ResolveErrorKindInternal, ResponseError,
};
use tokio::sync::{
mpsc::{self, Receiver, Sender},
Expand Down Expand Up @@ -67,8 +67,18 @@ pub async fn dns_worker(mut rx: Receiver<DnsRequest>, pid: Option<u64>) -> Resul
while let Some(DnsRequest { request, tx }) = rx.recv().await {
trace!("dns_worker -> request {:#?}", request);

let result = dns_lookup(root_path.as_path(), request.node);
if let Err(result) = tx.send(GetAddrInfoResponse(result.await)) {
let result = dns_lookup(root_path.as_path(), request.node)
.await
.map_err(|err| {
error!("dns_lookup -> ResponseError:: {err:?}");
match err {
ResponseError::DnsLookup(err) => ResponseError::DnsLookup(err),
_ => ResponseError::DnsLookup(DnsLookupError {
kind: ResolveErrorKindInternal::Unknown,
}),
}
});
if let Err(result) = tx.send(GetAddrInfoResponse(result)) {
error!("couldn't send result to caller {result:?}");
}
}
Expand Down

0 comments on commit ecff9f8

Please sign in to comment.