Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion gateway-test-utils/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub const DEFAULT_SP_SIM_CONFIG: &str =
pub struct GatewayTestContext {
pub client: gateway_client::Client,
pub server: omicron_gateway::Server,
pub port: u16,
port: u16,
pub simrack: SimRack,
pub logctx: LogContext,
pub gateway_id: Uuid,
Expand All @@ -47,6 +47,10 @@ pub struct GatewayTestContext {
}

impl GatewayTestContext {
pub fn address(&self) -> SocketAddrV6 {
SocketAddrV6::new(Ipv6Addr::LOCALHOST, self.port, 0, 0)
}

pub fn mgs_backends(&self) -> watch::Receiver<AllBackends> {
self.resolver_backends.clone()
}
Expand Down
3 changes: 2 additions & 1 deletion nexus/reconfigurator/execution/src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ pub fn overridables_for_test(
for (id_str, switch_slot) in scrimlets {
let sled_id = id_str.parse().unwrap();
let ip = Ipv6Addr::LOCALHOST;
let mgs_port = cptestctx.gateway.get(&switch_slot).unwrap().port;
let mgs_port =
cptestctx.gateway.get(&switch_slot).unwrap().address().port();
let dendrite_port =
cptestctx.dendrite.read().unwrap().get(&switch_slot).unwrap().port;
let mgd_port = cptestctx.mgd.get(&switch_slot).unwrap().port;
Expand Down
4 changes: 1 addition & 3 deletions nexus/src/app/sagas/instance_start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,6 @@ async fn sis_ensure_running(
#[cfg(test)]
mod test {
use core::time::Duration;
use std::net::SocketAddrV6;

use crate::app::sagas::disk_delete::test::ExpungeTestHarness;
use crate::app::sagas::disk_delete::test::create_disk;
Expand Down Expand Up @@ -1493,8 +1492,7 @@ mod test {
// Reuse the port number from the removed Switch0 to start a new dendrite instance
let nexus_address = cptestctx.internal_client.bind_address;
let mgs = cptestctx.gateway.get(&SwitchSlot::Switch0).unwrap();
let mgs_address =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, mgs.port, 0, 0).into();
let mgs_address = mgs.address().into();

// Test fault recovery for nat propogation
// Start a new dendrite instance for switch0
Expand Down
12 changes: 6 additions & 6 deletions nexus/src/app/sagas/instance_update/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2777,13 +2777,13 @@ mod test {
cptestctx: &ControlPlaneTestContext,
switch0_port: u16,
) {
use std::net::Ipv6Addr;
use std::net::SocketAddrV6;

let nexus_address = cptestctx.internal_client.bind_address;
let mgs = cptestctx.gateway.get(&SwitchSlot::Switch0).unwrap();
let mgs_address =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, mgs.port, 0, 0).into();
let mgs_address = cptestctx
.gateway
.get(&SwitchSlot::Switch0)
.unwrap()
.address()
.into();

let new_switch0 =
omicron_test_utils::dev::dendrite::DendriteInstance::start(
Expand Down
8 changes: 1 addition & 7 deletions nexus/test-utils/src/nexus_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,7 @@ impl<N: NexusServer> ControlPlaneTestContext<N> {
};

let mgs = self.gateway.get(&switch_slot).unwrap();
let mgs_addr = std::net::SocketAddrV6::new(
std::net::Ipv6Addr::LOCALHOST,
mgs.port,
0,
0,
)
.into();
let mgs_addr = mgs.address().into();

let dendrite =
omicron_test_utils::dev::dendrite::DendriteInstance::start(
Expand Down
9 changes: 3 additions & 6 deletions nexus/test-utils/src/starter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,8 +422,7 @@ impl<'a, N: NexusServer> ControlPlaneStarter<'a, N> {
let log = &self.logctx.log;
debug!(log, "Starting Dendrite"; "switch_slot" => ?switch_slot);
let mgs = self.gateway.get(&switch_slot).unwrap();
let mgs_addr =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, mgs.port, 0, 0).into();
let mgs_addr = mgs.address().into();

// Set up a stub instance of dendrite
let dendrite = dev::dendrite::DendriteInstance::start(
Expand All @@ -448,9 +447,7 @@ impl<'a, N: NexusServer> ControlPlaneStarter<'a, N> {
pub async fn start_mgd(&mut self, switch_slot: SwitchSlot) {
let log = &self.logctx.log;
debug!(log, "Starting mgd"; "switch_slot" => ?switch_slot);
let mgs = self.gateway.get(&switch_slot).unwrap();
let mgs_addr =
SocketAddrV6::new(Ipv6Addr::LOCALHOST, mgs.port, 0, 0).into();
let mgs_addr = self.gateway.get(&switch_slot).unwrap().address().into();

// Set up an instance of mgd
let mgd =
Expand Down Expand Up @@ -484,7 +481,7 @@ impl<'a, N: NexusServer> ControlPlaneStarter<'a, N> {
sled_id,
Ipv6Addr::LOCALHOST,
self.dendrite.read().unwrap().get(&switch_slot).unwrap().port,
self.gateway.get(&switch_slot).unwrap().port,
self.gateway.get(&switch_slot).unwrap().address().port(),
self.mgd.get(&switch_slot).unwrap().port,
)
.unwrap()
Expand Down
8 changes: 8 additions & 0 deletions sled-agent/scrimlet-reconcilers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ workspace = true

[dependencies]
chrono.workspace = true
daft.workspace = true
dpd-client.workspace = true
futures.workspace = true
gateway-client.workspace = true
gateway-types.workspace = true
macaddr.workspace = true
mg-admin-client.workspace = true
omicron-common.workspace = true
omicron-uuid-kinds.workspace = true
reqwest.workspace = true
sled-agent-types.workspace = true
slog.workspace = true
Expand All @@ -24,13 +28,17 @@ tokio.workspace = true
omicron-workspace-hack.workspace = true

[dev-dependencies]
anyhow.workspace = true
assert_matches.workspace = true
dropshot.workspace = true
gateway-messages.workspace = true
gateway-test-utils.workspace = true
httpmock.workspace = true
omicron-test-utils.workspace = true
proptest.workspace = true
serde_json.workspace = true
sled-agent-types = { workspace = true, features = ["testing"] }
test-strategy.workspace = true

[features]
testing = []
40 changes: 32 additions & 8 deletions sled-agent/scrimlet-reconcilers/src/dpd_reconciler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,35 @@ use crate::switch_zone_slot::ThisSledSwitchSlot;
use dpd_client::Client;
use sled_agent_types::system_networking::SystemNetworkingConfig;
use slog::Logger;
use slog::info;
use std::time::Duration;

mod nat;

pub use nat::DpdNatReconcilerStatus;
pub use nat::DpdNatReconcilerStatusNatEntry;
pub use nat::DpdNatReconcilerStatusNatEntryFailure;

#[derive(Debug, Clone)]
pub struct DpdReconcilerStatus {
pub todo_status: (),
/// Result of reconciling service zone NAT entries
pub nat_status: DpdNatReconcilerStatus,
}

impl slog::KV for DpdReconcilerStatus {
fn serialize(
&self,
_record: &slog::Record<'_>,
record: &slog::Record<'_>,
serializer: &mut dyn slog::Serializer,
) -> slog::Result {
serializer.emit_str("dpd-reconciler".into(), "not yet implemented")
let Self { nat_status } = self;
nat_status.serialize(record, serializer)
}
}

#[derive(Debug)]
pub(crate) struct DpdReconciler {
_client: Client,
client: Client,
_switch_slot: ThisSledSwitchSlot,
}

Expand All @@ -45,14 +54,29 @@ impl Reconciler for DpdReconciler {
switch_slot: ThisSledSwitchSlot,
parent_log: &Logger,
) -> Self {
Self { _client: mode.dpd_client(parent_log), _switch_slot: switch_slot }
Self { client: mode.dpd_client(parent_log), _switch_slot: switch_slot }
}

async fn do_reconciliation(
&mut self,
_system_networking_config: &SystemNetworkingConfig,
_log: &Logger,
system_networking_config: &SystemNetworkingConfig,
log: &Logger,
) -> Self::Status {
DpdReconcilerStatus { todo_status: () }
let nat_status = if let Some(nat_entries) = system_networking_config
.blueprint_external_networking_config
.as_ref()
.map(|config| &config.service_zone_nat_entries)
{
nat::reconcile(&self.client, nat_entries, log).await
} else {
DpdNatReconcilerStatus::NoNatEntriesConfig
};

info!(
log, "dpd reconciliation completed";
&nat_status,
);

DpdReconcilerStatus { nat_status }
}
}
Loading
Loading