Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

storage controller: validate DNS of registering nodes #7101

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions control_plane/attachment_service/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,30 @@ impl Service {
}
}

// We do not require that a node is actually online when registered (it will start life
// with it's availability set to Offline), but we _do_ require that its DNS record exists. We're
// therefore not immune to asymmetric L3 connectivity issues, but we are protected against nodes
// that register themselves with a broken DNS config. We check only the HTTP hostname, because
// the postgres hostname might only be resolvable to clients (e.g. if we're on a different VPC than clients).
if tokio::net::lookup_host(format!(
"{}:{}",
register_req.listen_http_addr, register_req.listen_http_port
))
.await
.is_err()
{
// If we have a transient DNS issue, it's up to the caller to retry their registration. Because
// we can't robustly distinguish between an intermittent issue and a totally bogus DNS situation,
// we return a soft 503 error, to encourage callers to retry past transient issues.
return Err(ApiError::ResourceUnavailable(
format!(
"Node {} tried to register with unknown DNS name '{}'",
register_req.node_id, register_req.listen_http_addr
)
.into(),
));
}

// Ordering: we must persist the new node _before_ adding it to in-memory state.
// This ensures that before we use it for anything or expose it via any external
// API, it is guaranteed to be available after a restart.
Expand Down