Skip to content

Commit

Permalink
[reconfigurator] Remove external networking CRDB records for expunged…
Browse files Browse the repository at this point in the history
… zones (#5613)

Testing this on a4x2; after RSS, we have 7 services with external
networking:

```
root@oxz_switch:~# omdb db network list-eips
 IP                PORTS        KIND      STATE     OWNER_KIND  OWNER_ID                              OWNER_NAME   OWNER_DISPOSITION
 198.51.100.20/32  0/65535      floating  Attached  service     468417ce-2edd-4c54-9162-b06d6424fbc9  ExternalDns  in service
 198.51.100.21/32  0/65535      floating  Attached  service     20d58632-4d53-4e93-97d3-3f594e794d08  ExternalDns  in service
 198.51.100.22/32  0/65535      floating  Attached  service     bd8d80b2-d04a-4372-ad9e-17579f27e89f  Nexus        in service
 198.51.100.23/32  0/65535      floating  Attached  service     32121854-7847-4edb-be06-78c0accbbcf4  Nexus        in service
 198.51.100.24/32  0/65535      floating  Attached  service     de48fe95-3757-46ed-811d-1bce5a749a10  Nexus        in service
 198.51.100.25/32  0/16383      SNAT      Attached  service     e33ef135-cb35-4514-b6cd-058674b35226  Ntp          in service
 198.51.100.26/32  16384/32767  SNAT      Attached  service     cb4e511d-d06d-4fac-bc08-12fe181876b4  Ntp          in service

root@oxz_switch:~# omdb db network list-vnics
 IP             MAC                SLOT  PRIMARY  KIND     SUBNET         PARENT_ID                             PARENT_NAME
 172.30.1.5/32  A8:40:25:FF:C7:6E  0     true     service  172.30.1.0/24  468417ce-2edd-4c54-9162-b06d6424fbc9  external-dns-468417ce-2edd-4c54-9162-b06d6424fbc9
 172.30.1.6/32  A8:40:25:FF:E6:99  0     true     service  172.30.1.0/24  20d58632-4d53-4e93-97d3-3f594e794d08  external-dns-20d58632-4d53-4e93-97d3-3f594e794d08
 172.30.2.5/32  A8:40:25:FF:8B:B8  0     true     service  172.30.2.0/24  bd8d80b2-d04a-4372-ad9e-17579f27e89f  nexus-bd8d80b2-d04a-4372-ad9e-17579f27e89f
 172.30.2.6/32  A8:40:25:FF:D7:82  0     true     service  172.30.2.0/24  32121854-7847-4edb-be06-78c0accbbcf4  nexus-32121854-7847-4edb-be06-78c0accbbcf4
 172.30.2.7/32  A8:40:25:FF:AF:30  0     true     service  172.30.2.0/24  de48fe95-3757-46ed-811d-1bce5a749a10  nexus-de48fe95-3757-46ed-811d-1bce5a749a10
 172.30.3.5/32  A8:40:25:FF:84:53  0     true     service  172.30.3.0/24  e33ef135-cb35-4514-b6cd-058674b35226  ntp-e33ef135-cb35-4514-b6cd-058674b35226
```

After expunging `g1` (running Nexus and Boundary NTP) and adding `g2`
(which gained a Nexus from Reconfigurator's goal of staying at 3), we
see that one of the Nexuses has been replaced, and one of the boundary
NTP records is gone:

```
root@oxz_switch:~# omdb db network list-eips
 IP                PORTS    KIND      STATE     OWNER_KIND  OWNER_ID                              OWNER_NAME   OWNER_DISPOSITION
 198.51.100.20/32  0/65535  floating  Attached  service     468417ce-2edd-4c54-9162-b06d6424fbc9  ExternalDns  in service
 198.51.100.21/32  0/65535  floating  Attached  service     20d58632-4d53-4e93-97d3-3f594e794d08  ExternalDns  in service
 198.51.100.23/32  0/65535  floating  Attached  service     32121854-7847-4edb-be06-78c0accbbcf4  Nexus        in service
 198.51.100.24/32  0/65535  floating  Attached  service     de48fe95-3757-46ed-811d-1bce5a749a10  Nexus        in service
 198.51.100.25/32  0/16383  SNAT      Attached  service     e33ef135-cb35-4514-b6cd-058674b35226  Ntp          in service
 198.51.100.27/32  0/65535  floating  Attached  service     44e26da6-8998-4204-b79c-a4e68b0beeab  Nexus        in service
root@oxz_switch:~# omdb db network list-vnics
 IP             MAC                SLOT  PRIMARY  KIND     SUBNET         PARENT_ID                             PARENT_NAME
 172.30.1.5/32  A8:40:25:FF:C7:6E  0     true     service  172.30.1.0/24  468417ce-2edd-4c54-9162-b06d6424fbc9  external-dns-468417ce-2edd-4c54-9162-b06d6424fbc9
 172.30.1.6/32  A8:40:25:FF:E6:99  0     true     service  172.30.1.0/24  20d58632-4d53-4e93-97d3-3f594e794d08  external-dns-20d58632-4d53-4e93-97d3-3f594e794d08
 172.30.2.6/32  A8:40:25:FF:D7:82  0     true     service  172.30.2.0/24  32121854-7847-4edb-be06-78c0accbbcf4  nexus-32121854-7847-4edb-be06-78c0accbbcf4
 172.30.2.7/32  A8:40:25:FF:AF:30  0     true     service  172.30.2.0/24  de48fe95-3757-46ed-811d-1bce5a749a10  nexus-de48fe95-3757-46ed-811d-1bce5a749a10
 172.30.2.8/32  A8:40:25:FF:80:00  0     true     service  172.30.2.0/24  44e26da6-8998-4204-b79c-a4e68b0beeab  nexus-44e26da6-8998-4204-b79c-a4e68b0beeab
 172.30.3.5/32  A8:40:25:FF:84:53  0     true     service  172.30.3.0/24  e33ef135-cb35-4514-b6cd-058674b35226  ntp-e33ef135-cb35-4514-b6cd-058674b35226
```
  • Loading branch information
jgallagher authored Apr 25, 2024
1 parent 1433453 commit 4fda855
Show file tree
Hide file tree
Showing 11 changed files with 1,266 additions and 1,056 deletions.
2 changes: 2 additions & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions dev-tools/reconfigurator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ impl ReconfiguratorSim {
for (_, zone) in
parent_blueprint.all_omicron_zones(BlueprintZoneFilter::All)
{
if let Some(external_ip) = zone.zone_type.external_ip() {
if let Some((external_ip, nic)) =
zone.zone_type.external_networking()
{
builder
.add_omicron_zone_external_ip(zone.id, external_ip)
.context("adding omicron zone external IP")?;
}
if let Some(nic) = zone.zone_type.opte_vnic() {
let nic = OmicronZoneNic {
id: nic.id,
mac: nic.mac,
Expand Down
8 changes: 5 additions & 3 deletions nexus/db-model/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,10 @@ impl BpOmicronZone {
sled_id: SledUuid,
blueprint_zone: &BlueprintZoneConfig,
) -> Result<Self, anyhow::Error> {
let external_ip_id =
blueprint_zone.zone_type.external_ip().map(|ip| ip.id());
let external_ip_id = blueprint_zone
.zone_type
.external_networking()
.map(|(ip, _)| ip.id());
let zone = OmicronZone::new(
sled_id,
blueprint_zone.id.into_untyped_uuid(),
Expand Down Expand Up @@ -381,7 +383,7 @@ impl BpOmicronZoneNic {
blueprint_id: Uuid,
zone: &BlueprintZoneConfig,
) -> Result<Option<BpOmicronZoneNic>, anyhow::Error> {
let Some(nic) = zone.zone_type.opte_vnic() else {
let Some((_, nic)) = zone.zone_type.external_networking() else {
return Ok(None);
};
let nic = OmicronZoneNic::new(zone.id.into_untyped_uuid(), nic)?;
Expand Down
2 changes: 2 additions & 0 deletions nexus/reconfigurator/execution/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ pq-sys = "*"
omicron-workspace-hack.workspace = true

[dev-dependencies]
async-bb8-diesel.workspace = true
diesel.workspace = true
httptest.workspace = true
ipnet.workspace = true
nexus-reconfigurator-planning.workspace = true
Expand Down
Loading

0 comments on commit 4fda855

Please sign in to comment.