Skip to content

Commit

Permalink
queue: revise fallback site_name for failed DNS lookups
Browse files Browse the repository at this point in the history
Previously, we'd use the full scheduled queue name in this case,
which is bad because that can include campaign and tenant information,
which is not really what we want to see in the site name; site names
represent the source -> destination at a more physical level than
the campaign and tenant concept.

Since failed DNS lookups result in messages that cannot be routed,
the site name is less meaningful for this case.

What we do here is take the effective routing domain and prefix
with either NXDOMAIN (for the most likely cause of hitting this code
path) or DNSFAIL (for any other kind of problem with DNS resolution,
which is likely infrastructure related).
  • Loading branch information
wez committed Sep 18, 2024
1 parent d3b5166 commit b6a73f0
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion crates/kumod/src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,28 @@ impl Queue {
.await
{
Ok(ready_name) => ready_name.site_name,
Err(_) => name.clone(),
Err(err) => {
// DNS resolution failed for whatever reason. We need to cook up a reasonable
// site_name even though we cannot actually establish a connection or ready
// queue for this domain.
// We'll base it off the effective routing domain, but throw in a string to
// help indicate at a glance that there is an issue with its DNS
let reason = format!("{err:#}");
let reason = if reason.contains("NXDOMAIN") {
"NXDOMAIN"
} else {
// Any other DNS resolution failure
"DNSFAIL"
};

let components = QueueNameComponents::parse(&name);
let routing_domain = components
.routing_domain
.as_deref()
.unwrap_or(&components.domain);

format!("{reason}:{routing_domain}")
}
};

let name = Arc::new(name);
Expand Down

0 comments on commit b6a73f0

Please sign in to comment.