Skip to content

Commit

Permalink
[omicron-zones] ensure name_prefix for clickhouse-server is valid (#6312
Browse files Browse the repository at this point in the history
)

Followup from #6297 -- `name_prefix` requires dashes.
  • Loading branch information
sunshowers authored Aug 13, 2024
1 parent b6e9078 commit e48cd90
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
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 nexus-sled-agent-shared/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ omicron-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true
sled-hardware-types.workspace = true
strum.workspace = true
uuid.workspace = true
28 changes: 26 additions & 2 deletions nexus-sled-agent-shared/src/inventory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use serde::{Deserialize, Serialize};
// Export this type for convenience -- this way, dependents don't have to
// depend on sled-hardware-types.
pub use sled_hardware_types::Baseboard;
use strum::EnumIter;
use uuid::Uuid;

/// Identifies information about disks which may be attached to Sleds.
Expand Down Expand Up @@ -381,7 +382,9 @@ impl OmicronZoneType {
/// the four representations if at all possible. If you must add a new one,
/// please add it here rather than doing something ad-hoc in the calling code
/// so it's more legible.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
#[derive(
Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, EnumIter,
)]
pub enum ZoneKind {
BoundaryNtp,
Clickhouse,
Expand Down Expand Up @@ -453,7 +456,7 @@ impl ZoneKind {
ZoneKind::BoundaryNtp | ZoneKind::InternalNtp => Self::NTP_PREFIX,
ZoneKind::Clickhouse => "clickhouse",
ZoneKind::ClickhouseKeeper => "clickhouse-keeper",
ZoneKind::ClickhouseServer => "clickhouse_server",
ZoneKind::ClickhouseServer => "clickhouse-server",
// Note "cockroach" for historical reasons.
ZoneKind::CockroachDb => "cockroach",
ZoneKind::Crucible => "crucible",
Expand Down Expand Up @@ -486,3 +489,24 @@ impl ZoneKind {
}
}
}

#[cfg(test)]
mod tests {
use omicron_common::api::external::Name;
use strum::IntoEnumIterator;

use super::*;

#[test]
fn test_name_prefixes() {
for zone_kind in ZoneKind::iter() {
let name_prefix = zone_kind.name_prefix();
name_prefix.parse::<Name>().unwrap_or_else(|e| {
panic!(
"failed to parse name prefix {:?} for zone kind {:?}: {}",
name_prefix, zone_kind, e
);
});
}
}
}

0 comments on commit e48cd90

Please sign in to comment.