-
Notifications
You must be signed in to change notification settings - Fork 40
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
update external DNS during blueprint execution #5212
Changes from 39 commits
bb9d3df
c48aa07
c7fad86
34e5c3f
f2771fd
7903de9
206a7b0
453f851
ca69595
728537f
139a28e
e88c2c4
ca1d630
ce06eee
54dd75b
b05dacd
0a153ea
757018e
50394fe
6fa022e
d339979
c0af241
f00e7e0
a259938
4e7e05c
1b76792
1c22f48
2b5c89b
2781013
9233548
d322a96
b2cb116
2e8d018
5648f86
c2041d8
35946f3
7028e0b
7ccbc8d
a706479
ef535d4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ use crate::db::model::Rack; | |
use crate::db::model::Zpool; | ||
use crate::db::pagination::paginated; | ||
use crate::db::pool::DbConnection; | ||
use crate::transaction_retry::OptionalError; | ||
use async_bb8_diesel::AsyncConnection; | ||
use async_bb8_diesel::AsyncRunQueryDsl; | ||
use chrono::Utc; | ||
|
@@ -44,6 +43,8 @@ use nexus_db_model::PasswordHashString; | |
use nexus_db_model::SiloUser; | ||
use nexus_db_model::SiloUserPasswordHash; | ||
use nexus_db_model::SledUnderlaySubnetAllocation; | ||
use nexus_types::deployment::Blueprint; | ||
use nexus_types::deployment::OmicronZoneType; | ||
use nexus_types::external_api::params as external_params; | ||
use nexus_types::external_api::shared; | ||
use nexus_types::external_api::shared::IdentityType; | ||
|
@@ -54,6 +55,7 @@ use nexus_types::internal_api::params as internal_params; | |
use omicron_common::api::external::DataPageParams; | ||
use omicron_common::api::external::Error; | ||
use omicron_common::api::external::IdentityMetadataCreateParams; | ||
use omicron_common::api::external::InternalContext; | ||
use omicron_common::api::external::ListResultVec; | ||
use omicron_common::api::external::LookupType; | ||
use omicron_common::api::external::ResourceType; | ||
|
@@ -793,60 +795,49 @@ impl DataStore { | |
pub async fn nexus_external_addresses( | ||
&self, | ||
opctx: &OpContext, | ||
blueprint: Option<&Blueprint>, | ||
) -> Result<(Vec<IpAddr>, Vec<DnsZone>), Error> { | ||
opctx.authorize(authz::Action::Read, &authz::DNS_CONFIG).await?; | ||
|
||
use crate::db::schema::external_ip::dsl as extip_dsl; | ||
use crate::db::schema::service::dsl as service_dsl; | ||
|
||
let err = OptionalError::new(); | ||
let conn = self.pool_connection_authorized(opctx).await?; | ||
self.transaction_retry_wrapper("nexus_external_addresses") | ||
.transaction(&conn, |conn| { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume the transaction was here to (attempt to?) ensure we got a consistent view of DNS zones + external IPs; does that not matter in practice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it should matter? The list of DNS zones cannot actually change today at all. If it did, I think you'd already have a problem because we're constructing a list of DNS names based on those zones, and that could become out of date by the time we try to write the DNS changes. The set of external IPs could, too, though only via Reconfigurator. Eventually I think we want to have even the Silo DNS changes happen through Reconfigurator, and then we'll know it will at least converge to correct. Anyway, since the list of DNS zones cannot change today, I think it makes sense to do this and revisit if/when we support that. |
||
let err = err.clone(); | ||
async move { | ||
let ips = extip_dsl::external_ip | ||
.inner_join( | ||
service_dsl::service.on(service_dsl::id | ||
.eq(extip_dsl::parent_id.assume_not_null())), | ||
) | ||
.filter(extip_dsl::parent_id.is_not_null()) | ||
.filter(extip_dsl::time_deleted.is_null()) | ||
.filter(extip_dsl::is_service) | ||
.filter( | ||
service_dsl::kind.eq(db::model::ServiceKind::Nexus), | ||
) | ||
.select(ExternalIp::as_select()) | ||
.get_results_async(&conn) | ||
.await? | ||
.into_iter() | ||
.map(|external_ip| external_ip.ip.ip()) | ||
.collect(); | ||
|
||
let dns_zones = self | ||
.dns_zones_list_all_on_connection( | ||
opctx, | ||
&conn, | ||
DnsGroup::External, | ||
) | ||
.await | ||
.map_err(|e| match e.retryable() { | ||
NotRetryable(not_retryable_err) => { | ||
err.bail(not_retryable_err) | ||
} | ||
Retryable(retryable_err) => retryable_err, | ||
})?; | ||
|
||
Ok((ips, dns_zones)) | ||
} | ||
}) | ||
let dns_zones = self | ||
.dns_zones_list_all(opctx, DnsGroup::External) | ||
.await | ||
.map_err(|e| { | ||
if let Some(err) = err.take() { | ||
return err.into(); | ||
} | ||
public_error_from_diesel(e, ErrorHandler::Server) | ||
}) | ||
.internal_context("listing DNS zones to list external addresses")?; | ||
|
||
let nexus_external_ips = if let Some(blueprint) = blueprint { | ||
blueprint | ||
.all_omicron_zones() | ||
.filter_map(|(_, z)| match z.zone_type { | ||
OmicronZoneType::Nexus { external_ip, .. } => { | ||
Some(external_ip) | ||
} | ||
_ => None, | ||
}) | ||
.collect() | ||
} else { | ||
use crate::db::schema::external_ip::dsl as extip_dsl; | ||
use crate::db::schema::service::dsl as service_dsl; | ||
|
||
let conn = self.pool_connection_authorized(opctx).await?; | ||
|
||
extip_dsl::external_ip | ||
.inner_join(service_dsl::service.on( | ||
service_dsl::id.eq(extip_dsl::parent_id.assume_not_null()), | ||
)) | ||
.filter(extip_dsl::parent_id.is_not_null()) | ||
.filter(extip_dsl::time_deleted.is_null()) | ||
.filter(extip_dsl::is_service) | ||
.filter(service_dsl::kind.eq(db::model::ServiceKind::Nexus)) | ||
.select(ExternalIp::as_select()) | ||
.get_results_async(&*conn) | ||
.await | ||
.map_err(|e| public_error_from_diesel(e, ErrorHandler::Server))? | ||
.into_iter() | ||
.map(|external_ip| external_ip.ip.ip()) | ||
.collect() | ||
}; | ||
|
||
Ok((nexus_external_ips, dns_zones)) | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely not a blocker on this PR: This makes me wonder if we should have typed generations like we're getting typed UUIDs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That does seem good.