From 7f37f2d59203512aac8534590c8eba773918d8e4 Mon Sep 17 00:00:00 2001 From: karencfv Date: Thu, 15 Aug 2024 16:48:28 +1200 Subject: [PATCH] optional clichouse topology build target flag --- package-manifest.toml | 5 +- package/src/bin/omicron-package.rs | 3 +- package/src/lib.rs | 13 +++++ package/src/target.rs | 23 ++++++++- smf/oximeter/replicated-cluster/manifest.xml | 52 ++++++++++++++++++++ smf/oximeter/{ => single-node}/manifest.xml | 0 6 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 smf/oximeter/replicated-cluster/manifest.xml rename smf/oximeter/{ => single-node}/manifest.xml (100%) diff --git a/package-manifest.toml b/package-manifest.toml index 66f5121de0..1e449f864a 100644 --- a/package-manifest.toml +++ b/package-manifest.toml @@ -140,11 +140,12 @@ source.type = "local" source.rust.binary_names = ["oximeter", "clickhouse-schema-updater"] source.rust.release = true source.paths = [ - { from = "smf/oximeter", to = "/var/svc/manifest/site/oximeter" }, + #{ from = "smf/oximeter", to = "/var/svc/manifest/site/oximeter" }, { from = "oximeter/db/schema", to = "/opt/oxide/oximeter/schema" }, + { from = "smf/oximeter/config.toml", to = "/var/svc/manifest/site/oximeter/config.toml" }, # TODO: Add something like rack-topology (slingle-sled vs multi-sled) to add `--replicated`? # Example: - # { from = "smf/oximeter/{{ch-cluster-topology}}", to = "/var/svc/manifest/site/oximeter" }, + { from = "smf/oximeter/{{clickhouse-topology}}/manifest.xml", to = "/var/svc/manifest/site/oximeter/manifest.xml" }, ] output.type = "zone" output.intermediate_only = true diff --git a/package/src/bin/omicron-package.rs b/package/src/bin/omicron-package.rs index b2b8703015..d66c990743 100644 --- a/package/src/bin/omicron-package.rs +++ b/package/src/bin/omicron-package.rs @@ -265,12 +265,13 @@ async fn do_target( format!("failed to create directory {}", target_dir) })?; match subcommand { - TargetCommand::Create { image, machine, switch, rack_topology } => { + TargetCommand::Create { image, machine, switch, rack_topology, clickhouse_topology } => { let target = KnownTarget::new( image.clone(), machine.clone(), switch.clone(), rack_topology.clone(), + clickhouse_topology.clone().expect("clickhouse topology should never be NONE") )?; let path = get_single_target(&target_dir, name).await?; diff --git a/package/src/lib.rs b/package/src/lib.rs index 2009de9dfe..8c6dabfceb 100644 --- a/package/src/lib.rs +++ b/package/src/lib.rs @@ -68,6 +68,19 @@ pub enum TargetCommand { /// fail in a single-sled environment. `single-sled` relaxes this /// requirement. rack_topology: crate::target::RackTopology, + + #[clap( + short, + long, + default_value = Some("single-node"), + required = false + )] + /// Specify whether clickhouse will be deployed as a replicated cluster + /// or single-node configuration. + /// + /// Replicated cluster configuration is an experimental feature to be + /// used only for testing. + clickhouse_topology: Option, }, /// List all existing targets List, diff --git a/package/src/target.rs b/package/src/target.rs index 589dba7870..484c75451a 100644 --- a/package/src/target.rs +++ b/package/src/target.rs @@ -62,6 +62,18 @@ pub enum RackTopology { SingleSled, } +/// Topology of the sleds within the rack. +#[derive(Clone, Debug, strum::EnumString, strum::Display, ValueEnum)] +#[strum(serialize_all = "kebab-case")] +#[clap(rename_all = "kebab-case")] +pub enum ClickhouseTopology { + /// Use configurations suitable for a replicated ClickHouse cluster deployment. + ReplicatedCluster, + + /// Use configurations suitable for a single-node ClickHouse deployment. + SingleNode, +} + /// A strongly-typed variant of [Target]. #[derive(Clone, Debug)] pub struct KnownTarget { @@ -69,6 +81,7 @@ pub struct KnownTarget { machine: Option, switch: Option, rack_topology: RackTopology, + clickhouse_topology: ClickhouseTopology, } impl KnownTarget { @@ -77,6 +90,7 @@ impl KnownTarget { machine: Option, switch: Option, rack_topology: RackTopology, + clickhouse_topology: ClickhouseTopology, ) -> Result { if matches!(image, Image::Trampoline) { if machine.is_some() { @@ -93,7 +107,7 @@ impl KnownTarget { bail!("'switch=asic' is only valid with 'machine=gimlet'"); } - Ok(Self { image, machine, switch, rack_topology }) + Ok(Self { image, machine, switch, rack_topology, clickhouse_topology }) } } @@ -104,6 +118,7 @@ impl Default for KnownTarget { machine: Some(Machine::NonGimlet), switch: Some(Switch::Stub), rack_topology: RackTopology::MultiSled, + clickhouse_topology: ClickhouseTopology::SingleNode, } } } @@ -119,6 +134,7 @@ impl From for Target { map.insert("switch".to_string(), switch.to_string()); } map.insert("rack-topology".to_string(), kt.rack_topology.to_string()); + map.insert("clickhouse-topology".to_string(), kt.clickhouse_topology.to_string()); Target(map) } } @@ -140,6 +156,7 @@ impl std::str::FromStr for KnownTarget { let mut machine = None; let mut switch = None; let mut rack_topology = None; + let mut clickhouse_topology = None; for (k, v) in target.0.into_iter() { match k.as_str() { @@ -155,6 +172,9 @@ impl std::str::FromStr for KnownTarget { "rack-topology" => { rack_topology = Some(v.parse()?); } + "clickhouse-topology" => { + clickhouse_topology = Some(v.parse()?); + } _ => { bail!( "Unknown target key {k}\nValid keys include: [{}]", @@ -173,6 +193,7 @@ impl std::str::FromStr for KnownTarget { machine, switch, rack_topology.unwrap_or(RackTopology::MultiSled), + clickhouse_topology.unwrap_or(ClickhouseTopology::SingleNode), ) } } diff --git a/smf/oximeter/replicated-cluster/manifest.xml b/smf/oximeter/replicated-cluster/manifest.xml new file mode 100644 index 0000000000..292d46b906 --- /dev/null +++ b/smf/oximeter/replicated-cluster/manifest.xml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/smf/oximeter/manifest.xml b/smf/oximeter/single-node/manifest.xml similarity index 100% rename from smf/oximeter/manifest.xml rename to smf/oximeter/single-node/manifest.xml