Skip to content

Commit

Permalink
Type fixes for nexus
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjstone committed Oct 17, 2023
1 parent af9ba38 commit 8e56948
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 14 deletions.
28 changes: 16 additions & 12 deletions nexus/src/app/rack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ use omicron_common::api::external::Name;
use omicron_common::api::external::NameOrId;
use omicron_common::api::external::SwitchLocation;
use omicron_common::api::internal::shared::ExternalPortDiscovery;
use sled_agent_client::types::EarlyNetworkConfigBody;
use sled_agent_client::types::{
BgpConfig, BgpPeerConfig, EarlyNetworkConfig, PortConfigV1,
RackNetworkConfig, RouteConfig as SledRouteConfig,
RackNetworkConfigV1, RouteConfig as SledRouteConfig,
};
use std::collections::BTreeMap;
use std::collections::BTreeSet;
Expand Down Expand Up @@ -596,7 +597,7 @@ impl super::Nexus {
.into_inner();

rack.rack_subnet =
result.rack_network_config.map(|x| x.rack_subnet.into());
result.body.rack_network_config.map(|x| x.rack_subnet.into());

self.datastore().rack_insert(opctx, &rack).await?;

Expand Down Expand Up @@ -696,16 +697,19 @@ impl super::Nexus {

let result = EarlyNetworkConfig {
generation: 0,
ntp_servers: Vec::new(), //TODO
rack_network_config: Some(RackNetworkConfig {
rack_subnet: subnet,
//TODO(ry) you are here. We need to remove these too. They are
// inconsistent with a generic set of addresses on ports.
infra_ip_first: Ipv4Addr::UNSPECIFIED,
infra_ip_last: Ipv4Addr::UNSPECIFIED,
ports,
bgp,
}),
schema_version: 1,
body: EarlyNetworkConfigBody {
ntp_servers: Vec::new(), //TODO
rack_network_config: Some(RackNetworkConfigV1 {
rack_subnet: subnet,
//TODO(ry) you are here. We need to remove these too. They are
// inconsistent with a generic set of addresses on ports.
infra_ip_first: Ipv4Addr::UNSPECIFIED,
infra_ip_last: Ipv4Addr::UNSPECIFIED,
ports,
bgp,
}),
},
};

Ok(result)
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/sagas/switch_port_settings_apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ pub(crate) fn apply_bootstore_update(
) -> Result<BootstoreNetworkPortChange, ActionError> {
let mut change = BootstoreNetworkPortChange::default();

let rack_net_config = match &mut config.rack_network_config {
let rack_net_config = match &mut config.body.rack_network_config {
Some(cfg) => cfg,
None => {
return Err(ActionError::action_failed(
Expand Down
2 changes: 1 addition & 1 deletion nexus/src/app/switch_port.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use omicron_common::api::external::{
use sled_agent_client::types::BgpConfig;
use sled_agent_client::types::BgpPeerConfig;
use sled_agent_client::types::{
EarlyNetworkConfig, PortConfigV1, RackNetworkConfig, RouteConfig,
EarlyNetworkConfig, PortConfigV1, RackNetworkConfigV1, RouteConfig,
};
use std::sync::Arc;
use uuid::Uuid;
Expand Down
19 changes: 19 additions & 0 deletions sled-agent/src/bootstrap/early_networking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,3 +738,22 @@ fn convert_fec(fec: &PortFec) -> dpd_client::types::PortFec {
PortFec::Rs => dpd_client::types::PortFec::Rs,
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn serialized_early_network_config_v0_to_v1_conversion() {
let v0 = EarlyNetworkConfigV0 {
generation: 1,
rack_subnet: Ipv6Addr::UNSPECIFIED,
ntp_servers: Vec::new(),
rack_network_config: Some(RackNetworkConfigV0 {
infra_ip_first: Ipv4Addr::UNSPECIFIED,
infra_ip_last: Ipv4Addr::UNSPECIFIED,
uplinks: vec![],
}),
};
}
}

0 comments on commit 8e56948

Please sign in to comment.