-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSS could provision external DNS zone (#2837)
- Loading branch information
1 parent
4d442b4
commit 687eaf8
Showing
19 changed files
with
284 additions
and
28 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
//! End-to-end test for external DNS | ||
//! | ||
//! External DNS is not yet configured with any DNS names. For now, this just | ||
//! tests basic connectivity. | ||
#![cfg(test)] | ||
|
||
use anyhow::{anyhow, Context as _, Result}; | ||
use omicron_sled_agent::rack_setup::config::SetupServiceConfig; | ||
use std::net::SocketAddr; | ||
use std::path::Path; | ||
use trust_dns_resolver::config::{ | ||
NameServerConfig, Protocol, ResolverConfig, ResolverOpts, | ||
}; | ||
use trust_dns_resolver::error::ResolveErrorKind; | ||
use trust_dns_resolver::TokioAsyncResolver; | ||
|
||
#[tokio::test] | ||
async fn dns_smoke() -> Result<()> { | ||
let dns_addr = dns_addr(); | ||
|
||
let mut resolver_config = ResolverConfig::new(); | ||
resolver_config.add_name_server(NameServerConfig { | ||
socket_addr: dns_addr, | ||
protocol: Protocol::Udp, | ||
tls_dns_name: None, | ||
trust_nx_responses: false, | ||
bind_addr: None, | ||
}); | ||
|
||
let resolver = | ||
TokioAsyncResolver::tokio(resolver_config, ResolverOpts::default()) | ||
.context("failed to create resolver")?; | ||
match resolver.lookup_ip("oxide.test.").await { | ||
Ok(_) => { | ||
Err(anyhow!("unexpectedly resolved made-up external DNS name")) | ||
} | ||
Err(error) => match error.kind() { | ||
ResolveErrorKind::NoRecordsFound { .. } => Ok(()), | ||
_ => Err(anyhow!( | ||
"unexpected error querying external DNS: {:?}", | ||
error | ||
)), | ||
}, | ||
} | ||
} | ||
|
||
fn dns_addr() -> SocketAddr { | ||
// If we can find config-rss.toml, grab the first address from the | ||
// configured services IP pool. Otherwise, choose a lab default. | ||
// (This is the same mechanism used for finding Nexus addresses.) | ||
let rss_config_path = Path::new(env!("CARGO_MANIFEST_DIR")) | ||
.join("../smf/sled-agent/non-gimlet/config-rss.toml"); | ||
if rss_config_path.exists() { | ||
if let Ok(config) = SetupServiceConfig::from_file(rss_config_path) { | ||
if let Some(addr) = config | ||
.internal_services_ip_pool_ranges | ||
.iter() | ||
.flat_map(|range| range.iter()) | ||
.next() | ||
{ | ||
return (addr, 53).into(); | ||
} | ||
} | ||
} | ||
|
||
([192, 168, 1, 20], 53).into() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod helpers; | ||
|
||
mod external_dns; | ||
mod instance_launch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.