Skip to content

Commit e48cd90

Browse files
authored
[omicron-zones] ensure name_prefix for clickhouse-server is valid (#6312)
Followup from #6297 -- `name_prefix` requires dashes.
1 parent b6e9078 commit e48cd90

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nexus-sled-agent-shared/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ omicron-workspace-hack.workspace = true
1414
schemars.workspace = true
1515
serde.workspace = true
1616
sled-hardware-types.workspace = true
17+
strum.workspace = true
1718
uuid.workspace = true

nexus-sled-agent-shared/src/inventory.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
2020
// Export this type for convenience -- this way, dependents don't have to
2121
// depend on sled-hardware-types.
2222
pub use sled_hardware_types::Baseboard;
23+
use strum::EnumIter;
2324
use uuid::Uuid;
2425

2526
/// Identifies information about disks which may be attached to Sleds.
@@ -381,7 +382,9 @@ impl OmicronZoneType {
381382
/// the four representations if at all possible. If you must add a new one,
382383
/// please add it here rather than doing something ad-hoc in the calling code
383384
/// so it's more legible.
384-
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
385+
#[derive(
386+
Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, EnumIter,
387+
)]
385388
pub enum ZoneKind {
386389
BoundaryNtp,
387390
Clickhouse,
@@ -453,7 +456,7 @@ impl ZoneKind {
453456
ZoneKind::BoundaryNtp | ZoneKind::InternalNtp => Self::NTP_PREFIX,
454457
ZoneKind::Clickhouse => "clickhouse",
455458
ZoneKind::ClickhouseKeeper => "clickhouse-keeper",
456-
ZoneKind::ClickhouseServer => "clickhouse_server",
459+
ZoneKind::ClickhouseServer => "clickhouse-server",
457460
// Note "cockroach" for historical reasons.
458461
ZoneKind::CockroachDb => "cockroach",
459462
ZoneKind::Crucible => "crucible",
@@ -486,3 +489,24 @@ impl ZoneKind {
486489
}
487490
}
488491
}
492+
493+
#[cfg(test)]
494+
mod tests {
495+
use omicron_common::api::external::Name;
496+
use strum::IntoEnumIterator;
497+
498+
use super::*;
499+
500+
#[test]
501+
fn test_name_prefixes() {
502+
for zone_kind in ZoneKind::iter() {
503+
let name_prefix = zone_kind.name_prefix();
504+
name_prefix.parse::<Name>().unwrap_or_else(|e| {
505+
panic!(
506+
"failed to parse name prefix {:?} for zone kind {:?}: {}",
507+
name_prefix, zone_kind, e
508+
);
509+
});
510+
}
511+
}
512+
}

0 commit comments

Comments
 (0)