Skip to content
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

[sled-agent] Remove 'upsert_filesystem' API #6757

Draft
wants to merge 137 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
5c2e5b0
[wip] Starting sled agent API to manage datasets explicitly
smklein Jul 18, 2024
1709d80
Merge branch 'main' into explicit-datasets
smklein Jul 22, 2024
a80313d
list implementation
smklein Jul 22, 2024
7193d1b
Tests
smklein Jul 22, 2024
9464cc1
schemas n stuff
smklein Jul 22, 2024
fb23666
Merge branch 'main' into explicit-datasets
smklein Jul 23, 2024
817a397
The sled agent side of datasets in inventory
smklein Jul 24, 2024
54b4658
Plumb inventory into nexus, omdb
smklein Jul 25, 2024
29c4eb7
Merge branch 'main' into explicit-datasets
smklein Jul 25, 2024
ff27801
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 25, 2024
75f006b
Merge branch 'main' into explicit-datasets
smklein Jul 26, 2024
559db4f
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 26, 2024
24d93a8
Fix mismerge
smklein Jul 26, 2024
e2dd6d7
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 26, 2024
178e20e
Clippy and helios
smklein Jul 26, 2024
530bf08
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 26, 2024
cf3f35c
openapi
smklein Jul 26, 2024
021aa2f
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 26, 2024
67bf6fa
schema upgrade
smklein Jul 26, 2024
11f49fb
More broad support for datasets
smklein Jul 30, 2024
b999bf7
make it a schema change
smklein Jul 30, 2024
fac6456
Merge branch 'main' into explicit-datasets
smklein Jul 30, 2024
9298d83
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 30, 2024
1baf7dd
welp I guess I changed some db queries
smklein Jul 30, 2024
fdf0644
queries
smklein Jul 30, 2024
a042439
Merge branch 'main' into explicit-datasets
smklein Jul 31, 2024
d70f9bc
Merge branch 'explicit-datasets' into inventory-datasets
smklein Jul 31, 2024
07511e9
Neck deep in reconfigurator
smklein Aug 2, 2024
d753dbd
sled_ensure_datasets mostly filled out
smklein Aug 5, 2024
37b4907
deploy_datasets
smklein Aug 5, 2024
3b092e7
Using disposition to try to delete datasets
smklein Aug 6, 2024
1cd5a96
Passing reconfigurator tests
smklein Aug 6, 2024
940c240
Fix BP loading, add datasets to representative blueprint
smklein Aug 7, 2024
9c27213
Merge branch 'main' into explicit-datasets
smklein Aug 7, 2024
c562125
Optional properties still get set
smklein Aug 7, 2024
c7a5adf
clippy
smklein Aug 7, 2024
181507c
fmt
smklein Aug 7, 2024
8e1df07
str not string
smklein Aug 7, 2024
93134c2
cockroachdb, not cockroach_db
smklein Aug 7, 2024
d88d541
generation numbers
smklein Aug 7, 2024
95ebbb8
review feedback
smklein Aug 7, 2024
994757e
Serialize via string, not tag
smklein Aug 7, 2024
7156ba0
safer API for Dataset::new
smklein Aug 8, 2024
5a91c8f
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 8, 2024
dac802b
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 8, 2024
de22ac0
fmt
smklein Aug 8, 2024
018f1f7
Schemas, expectorate
smklein Aug 8, 2024
14a2dc4
merge main into branch, manually impl JsonSchema
sunshowers Aug 8, 2024
aa60254
update schema JSONs, add replace
sunshowers Aug 8, 2024
5883527
reconfigurator execution tests
smklein Aug 9, 2024
1a5684c
Datasets in input, test for sled_ensure_datasets, more bp verification
smklein Aug 10, 2024
67c5d7e
Merge branch 'main' into explicit-datasets
smklein Aug 10, 2024
927efd1
Merge remote-tracking branch 'origin/explicit-datasets' into explicit…
smklein Aug 10, 2024
3e14cc4
Fix schema
smklein Aug 10, 2024
4d41c5c
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 10, 2024
06066cc
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 10, 2024
f39bce3
more merging
smklein Aug 10, 2024
1f671c1
schema
smklein Aug 10, 2024
40f93ae
Merge branch 'main' into explicit-datasets
smklein Aug 22, 2024
0f8150f
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 22, 2024
2ba0125
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 22, 2024
2c5685f
Fix clickhouseserver datasetkind serialization
smklein Aug 26, 2024
077908d
Fix clickhouseserver datasetkind serialization
smklein Aug 26, 2024
5d8f513
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 26, 2024
4734eaa
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 26, 2024
a600494
Merge branch 'main' into explicit-datasets
smklein Aug 26, 2024
6f9cd0d
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 26, 2024
a26a207
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 26, 2024
a83450e
Add docs, use ByteCount more, better simulated inventory
smklein Aug 26, 2024
e8504a5
schema and openapi
smklein Aug 27, 2024
28e6497
Fix helios tests
smklein Aug 27, 2024
b9d3dcc
fmt
smklein Aug 27, 2024
0a63161
Merge branch 'main' into explicit-datasets
smklein Aug 28, 2024
c9f170e
Make CompressionAlgorithm strongly typed
smklein Aug 28, 2024
f5bc35a
Fixing helios-only tests, clippy
smklein Aug 28, 2024
474ec13
schemas
smklein Aug 28, 2024
8c52f4b
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 28, 2024
c4d5b3a
Merge branch 'main' into explicit-datasets
smklein Aug 28, 2024
042f786
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 28, 2024
f0ed1c3
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 28, 2024
38560d1
clippy
smklein Aug 28, 2024
5c5a856
Merge branch 'main' into explicit-datasets
smklein Aug 28, 2024
7b4083f
Merge branch 'explicit-datasets' into inventory-datasets
smklein Aug 28, 2024
77b3721
Pass byte values as single integers (no 'GiB' suffixes)
smklein Aug 28, 2024
e56e9a0
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Aug 28, 2024
d42e44a
comments
smklein Aug 28, 2024
bfe6e7f
more comments
smklein Aug 28, 2024
4f42f47
Make compression optional for back compat, fix tests
smklein Aug 29, 2024
70c8ede
Merge branch 'main' into explicit-datasets
smklein Sep 4, 2024
7693ef0
Merge branch 'explicit-datasets' into inventory-datasets
smklein Sep 4, 2024
ad7718b
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Sep 5, 2024
9e4da68
Started review feedback
smklein Sep 5, 2024
ec04e8b
Actually add the v5 schema
smklein Sep 5, 2024
a379e1b
Add filter
smklein Sep 5, 2024
4568f0c
Strongly typed CompressionAlgorithm
smklein Sep 5, 2024
45394b8
Better compare
smklein Sep 5, 2024
d30cfcb
fmt
smklein Sep 5, 2024
7b941a3
misc builder updates
smklein Sep 5, 2024
b103fd6
Review feedback
smklein Sep 5, 2024
26c578d
Fix tests
smklein Sep 5, 2024
4ac2d22
Update openapi
smklein Sep 5, 2024
830b67b
Merge branch 'main' into explicit-datasets
smklein Sep 6, 2024
bc29752
Merge branch 'explicit-datasets' into inventory-datasets
smklein Sep 6, 2024
67c2181
review feedback
smklein Sep 6, 2024
557dc22
Fix error wrapping in tests
smklein Sep 6, 2024
70f3cb6
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Sep 23, 2024
0cd8e67
Merge branch 'main' into explicit-datasets
smklein Sep 23, 2024
f3b7c88
Merge branch 'explicit-datasets' into inventory-datasets
smklein Sep 23, 2024
d1fab1d
Merge branch 'inventory-datasets' into nexus-requests-datasets
smklein Sep 23, 2024
5eb4d17
Merge branch 'main' into nexus-requests-datasets
smklein Sep 23, 2024
d4b730b
Fix reconfigurator registration
smklein Sep 23, 2024
8ce16e4
Feedback from 9/5 meeting
smklein Sep 23, 2024
40c2c8e
rustdocs
smklein Sep 24, 2024
990767e
Merge branch 'main' into nexus-requests-datasets
smklein Sep 25, 2024
20b7c62
Fixing merge issues
smklein Sep 25, 2024
fdab22a
Zone names, full enumeration
smklein Sep 25, 2024
50019ee
Make dataset creation/deletion dependent on target blueprint
smklein Sep 25, 2024
40bbfab
Clippy
smklein Sep 26, 2024
6abe0b9
Merge branch 'main' into nexus-requests-datasets
smklein Sep 26, 2024
24b0341
Shared zone name
smklein Sep 26, 2024
60ff044
.
smklein Sep 26, 2024
60c3c1a
sort
smklein Sep 26, 2024
7ee5cc5
Add extra safety checks
smklein Sep 26, 2024
d0ad50c
Comment on compression
smklein Sep 26, 2024
3ba53d6
reconfigurator format
smklein Sep 26, 2024
4a4fcf3
Compression algorithm comment
smklein Sep 26, 2024
3c7e771
current_target
smklein Sep 26, 2024
e5b8cf8
Merge branch 'main' into nexus-requests-datasets
smklein Sep 26, 2024
0749c9a
fix broken merge
smklein Sep 26, 2024
78daf5d
FOR UPDATE
smklein Sep 26, 2024
8085051
SELECT FOR UPDATE docs
smklein Sep 26, 2024
cda6bad
Merge branch 'main' into nexus-requests-datasets
smklein Sep 26, 2024
4de44ac
Merge branch 'main' into nexus-requests-datasets
smklein Oct 1, 2024
7f1f89f
schemas
smklein Oct 1, 2024
ea6925b
Merge branch 'main' into nexus-requests-datasets
smklein Oct 2, 2024
2186ec3
Fix mismerge
smklein Oct 2, 2024
3768792
Remove 'upsert_filesystem' API
smklein Oct 2, 2024
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
1 change: 1 addition & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions clients/sled-agent-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ progenitor::generate_api!(
replace = {
Baseboard = nexus_sled_agent_shared::inventory::Baseboard,
ByteCount = omicron_common::api::external::ByteCount,
DatasetsConfig = omicron_common::disk::DatasetsConfig,
DatasetKind = omicron_common::api::internal::shared::DatasetKind,
DiskIdentity = omicron_common::disk::DiskIdentity,
DiskVariant = omicron_common::disk::DiskVariant,
Expand Down
20 changes: 10 additions & 10 deletions common/src/api/internal/shared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ pub enum DatasetKind {
InternalDns,

// Zone filesystems
ZoneRoot,
Zone {
TransientZoneRoot,
TransientZone {
name: String,
},

Expand Down Expand Up @@ -922,15 +922,15 @@ impl DatasetKind {
match self {
Cockroach | Crucible | Clickhouse | ClickhouseKeeper
| ClickhouseServer | ExternalDns | InternalDns => true,
ZoneRoot | Zone { .. } | Debug | Update => false,
TransientZoneRoot | TransientZone { .. } | Debug | Update => false,
}
}

/// Returns the zone name, if this is a dataset for a zone filesystem.
///
/// Otherwise, returns "None".
pub fn zone_name(&self) -> Option<&str> {
if let DatasetKind::Zone { name } = self {
if let DatasetKind::TransientZone { name } = self {
Some(name)
} else {
None
Expand All @@ -954,8 +954,8 @@ impl fmt::Display for DatasetKind {
ClickhouseServer => "clickhouse_server",
ExternalDns => "external_dns",
InternalDns => "internal_dns",
ZoneRoot => "zone",
Zone { name } => {
TransientZoneRoot => "zone",
TransientZone { name } => {
write!(f, "zone/{}", name)?;
return Ok(());
}
Expand Down Expand Up @@ -985,12 +985,12 @@ impl FromStr for DatasetKind {
"clickhouse_server" => ClickhouseServer,
"external_dns" => ExternalDns,
"internal_dns" => InternalDns,
"zone" => ZoneRoot,
"zone" => TransientZoneRoot,
"debug" => Debug,
"update" => Update,
other => {
if let Some(name) = other.strip_prefix("zone/") {
Zone { name: name.to_string() }
TransientZone { name: name.to_string() }
} else {
return Err(DatasetKindParseError::UnknownDataset(
s.to_string(),
Expand Down Expand Up @@ -1080,8 +1080,8 @@ mod tests {
DatasetKind::ClickhouseServer,
DatasetKind::ExternalDns,
DatasetKind::InternalDns,
DatasetKind::ZoneRoot,
DatasetKind::Zone { name: String::from("myzone") },
DatasetKind::TransientZoneRoot,
DatasetKind::TransientZone { name: String::from("myzone") },
DatasetKind::Debug,
DatasetKind::Update,
];
Expand Down
37 changes: 37 additions & 0 deletions common/src/disk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::collections::BTreeMap;
use std::fmt;
use std::str::FromStr;
use uuid::Uuid;

use crate::{
Expand Down Expand Up @@ -186,6 +187,18 @@ impl GzipLevel {
}
}

impl FromStr for GzipLevel {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
let level = s.parse::<u8>()?;
if level < GZIP_LEVEL_MIN || level > GZIP_LEVEL_MAX {
bail!("Invalid gzip compression level: {level}");
}
Ok(Self(level))
}
}

#[derive(
Copy,
Clone,
Expand Down Expand Up @@ -224,6 +237,7 @@ pub enum CompressionAlgorithm {
Zle,
}

/// These match the arguments which can be passed to "zfs set compression=..."
impl fmt::Display for CompressionAlgorithm {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use CompressionAlgorithm::*;
Expand All @@ -242,6 +256,29 @@ impl fmt::Display for CompressionAlgorithm {
}
}

impl FromStr for CompressionAlgorithm {
type Err = anyhow::Error;

fn from_str(s: &str) -> Result<Self, Self::Err> {
use CompressionAlgorithm::*;
let c = match s {
"on" => On,
"" | "off" => Off,
"gzip" => Gzip,
"lz4" => Lz4,
"lzjb" => Lzjb,
"zle" => Zle,
_ => {
let Some(suffix) = s.strip_prefix("gzip-") else {
bail!("Unknown compression algorithm {s}");
};
GzipN { level: suffix.parse()? }
}
};
Ok(c)
}
}

/// Configuration information necessary to request a single dataset
#[derive(
Clone,
Expand Down
21 changes: 17 additions & 4 deletions dev-tools/reconfigurator-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,9 +618,12 @@ fn cmd_sled_show(
swriteln!(s, "sled {}", sled_id);
swriteln!(s, "subnet {}", sled_resources.subnet.net());
swriteln!(s, "zpools ({}):", sled_resources.zpools.len());
for (zpool, disk) in &sled_resources.zpools {
for (zpool, (disk, datasets)) in &sled_resources.zpools {
swriteln!(s, " {:?}", zpool);
swriteln!(s, " ↳ {:?}", disk);
swriteln!(s, " {:?}", disk);
for dataset in datasets {
swriteln!(s, " ↳ {:?}", dataset);
}
}
Ok(Some(s))
}
Expand Down Expand Up @@ -781,7 +784,12 @@ fn cmd_blueprint_edit(
.context("failed to add Nexus zone")?;
assert_matches::assert_matches!(
added,
EnsureMultiple::Changed { added: 1, removed: 0 }
EnsureMultiple::Changed {
added: 1,
updated: 0,
expunged: 0,
removed: 0
}
);
format!("added Nexus zone to sled {}", sled_id)
}
Expand All @@ -793,7 +801,12 @@ fn cmd_blueprint_edit(
.context("failed to add CockroachDB zone")?;
assert_matches::assert_matches!(
added,
EnsureMultiple::Changed { added: 1, removed: 0 }
EnsureMultiple::Changed {
added: 1,
updated: 0,
expunged: 0,
removed: 0
}
);
format!("added CockroachDB zone to sled {}", sled_id)
}
Expand Down
20 changes: 10 additions & 10 deletions dev-tools/reconfigurator-cli/tests/output/cmd-stdout
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ sled ..........<REDACTED_UUID>...........
subnet fd00:1122:3344:101::/64
zpools (10):
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
..........<REDACTED_UUID>........... (zpool)
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }
SledDisk { disk_identity: DiskIdentity { vendor: "fake-vendor", model: "fake-model", serial: "serial-..........<REDACTED_UUID>..........." }, disk_id: ..........<REDACTED_UUID>........... (physical_disk), policy: InService, state: Active }


> sled-add ..........<REDACTED_UUID>...........
Expand Down
19 changes: 9 additions & 10 deletions illumos-utils/src/running_zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@ use crate::dladm::Etherstub;
use crate::link::{Link, VnicAllocator};
use crate::opte::{Port, PortTicket};
use crate::svc::wait_for_service;
use crate::zone::{AddressRequest, ZONE_PREFIX};
use crate::zone::AddressRequest;
use crate::zpool::{PathInPool, ZpoolName};
use camino::{Utf8Path, Utf8PathBuf};
use camino_tempfile::Utf8TempDir;
use ipnetwork::IpNetwork;
use omicron_common::backoff;
use omicron_uuid_kinds::OmicronZoneUuid;
pub use oxlog::is_oxide_smf_log_file;
use slog::{error, info, o, warn, Logger};
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
Expand All @@ -26,7 +27,6 @@ use std::sync::Arc;
use std::sync::OnceLock;
#[cfg(target_os = "illumos")]
use std::thread;
use uuid::Uuid;

#[cfg(any(test, feature = "testing"))]
use crate::zone::MockZones as Zones;
Expand Down Expand Up @@ -947,12 +947,11 @@ impl InstalledZone {
///
/// This results in a zone name which is distinct across different zpools,
/// but stable and predictable across reboots.
pub fn get_zone_name(zone_type: &str, unique_name: Option<Uuid>) -> String {
let mut zone_name = format!("{}{}", ZONE_PREFIX, zone_type);
if let Some(suffix) = unique_name {
zone_name.push_str(&format!("_{}", suffix));
}
zone_name
pub fn get_zone_name(
zone_type: &str,
unique_name: Option<OmicronZoneUuid>,
) -> String {
crate::zone::zone_name(zone_type, unique_name)
}

/// Get the name of the bootstrap VNIC in the zone, if any.
Expand Down Expand Up @@ -1055,7 +1054,7 @@ pub struct ZoneBuilder<'a> {
// builder purposes - that is, skipping this field in the builder will
// still result in an `Ok(InstalledZone)` from `.install()`, rather than
// an `Err(InstallZoneError::IncompleteBuilder)`.
unique_name: Option<Uuid>,
unique_name: Option<OmicronZoneUuid>,
/// ZFS datasets to be accessed from within the zone.
datasets: Option<&'a [zone::Dataset]>,
/// Filesystems to mount within the zone.
Expand Down Expand Up @@ -1119,7 +1118,7 @@ impl<'a> ZoneBuilder<'a> {
}

/// Unique ID of the instance of the zone being created. (optional)
pub fn with_unique_name(mut self, uuid: Uuid) -> Self {
pub fn with_unique_name(mut self, uuid: OmicronZoneUuid) -> Self {
self.unique_name = Some(uuid);
self
}
Expand Down
9 changes: 9 additions & 0 deletions illumos-utils/src/zone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use crate::dladm::{EtherstubVnic, VNIC_PREFIX_BOOTSTRAP, VNIC_PREFIX_CONTROL};
use crate::zpool::PathInPool;
use crate::{execute, PFEXEC};
use omicron_common::address::SLED_PREFIX;
use omicron_uuid_kinds::OmicronZoneUuid;

const DLADM: &str = "/usr/sbin/dladm";
pub const IPADM: &str = "/usr/sbin/ipadm";
Expand All @@ -29,6 +30,14 @@ pub const ROUTE: &str = "/usr/sbin/route";
pub const ZONE_PREFIX: &str = "oxz_";
pub const PROPOLIS_ZONE_PREFIX: &str = "oxz_propolis-server_";

pub fn zone_name(prefix: &str, id: Option<OmicronZoneUuid>) -> String {
if let Some(id) = id {
format!("{ZONE_PREFIX}{}_{}", prefix, id)
} else {
format!("{ZONE_PREFIX}{}", prefix)
}
}

#[derive(thiserror::Error, Debug)]
enum Error {
#[error("Zone execution error: {0}")]
Expand Down
7 changes: 6 additions & 1 deletion live-tests/tests/test_nexus_add_remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ async fn test_nexus_add_remove(lc: &LiveTestContext) {
.context("adding Nexus zone")?;
assert_matches!(
count,
EnsureMultiple::Changed { added: 1, removed: 0 }
EnsureMultiple::Changed {
added: 1,
removed: 0,
updated: 0,
expunged: 0
}
);
Ok(())
},
Expand Down
Loading
Loading