Skip to content

Commit

Permalink
optional clichouse topology build target flag
Browse files Browse the repository at this point in the history
  • Loading branch information
karencfv committed Aug 15, 2024
1 parent 9829915 commit 7f37f2d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 4 deletions.
5 changes: 3 additions & 2 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion package/src/bin/omicron-package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down
13 changes: 13 additions & 0 deletions package/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::target::ClickhouseTopology>,
},
/// List all existing targets
List,
Expand Down
23 changes: 22 additions & 1 deletion package/src/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,26 @@ 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 {
image: Image,
machine: Option<Machine>,
switch: Option<Switch>,
rack_topology: RackTopology,
clickhouse_topology: ClickhouseTopology,
}

impl KnownTarget {
Expand All @@ -77,6 +90,7 @@ impl KnownTarget {
machine: Option<Machine>,
switch: Option<Switch>,
rack_topology: RackTopology,
clickhouse_topology: ClickhouseTopology,
) -> Result<Self> {
if matches!(image, Image::Trampoline) {
if machine.is_some() {
Expand All @@ -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 })
}
}

Expand All @@ -104,6 +118,7 @@ impl Default for KnownTarget {
machine: Some(Machine::NonGimlet),
switch: Some(Switch::Stub),
rack_topology: RackTopology::MultiSled,
clickhouse_topology: ClickhouseTopology::SingleNode,
}
}
}
Expand All @@ -119,6 +134,7 @@ impl From<KnownTarget> 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)
}
}
Expand All @@ -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() {
Expand All @@ -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: [{}]",
Expand All @@ -173,6 +193,7 @@ impl std::str::FromStr for KnownTarget {
machine,
switch,
rack_topology.unwrap_or(RackTopology::MultiSled),
clickhouse_topology.unwrap_or(ClickhouseTopology::SingleNode),
)
}
}
52 changes: 52 additions & 0 deletions smf/oximeter/replicated-cluster/manifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">

<service_bundle type='manifest' name='oximeter'>

<service name='oxide/oximeter' type='service' version='1'>
<create_default_instance enabled='true' />

<dependency name='multi_user' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/milestone/multi-user:default' />
</dependency>

<dependency name='zone_network_setup' grouping='require_all' restart_on='none'
type='service'>
<service_fmri value='svc:/oxide/zone-network-setup:default' />
</dependency>

<method_context>
<method_environment>
<envvar name="LD_LIBRARY_PATH" value="/opt/ooce/pgsql-13/lib/amd64" />
</method_environment>
</method_context>
<exec_method type='method' name='start'
exec='ctrun -l child -o noorphan,regent /opt/oxide/oximeter-collector/bin/oximeter run /var/svc/manifest/site/oximeter/config.toml --address %{config/address} --id %{config/id} --replicated &amp;'
timeout_seconds='0'>
</exec_method>

<exec_method type='method' name='stop' exec=':kill' timeout_seconds='0' />

<property_group name='config' type='application'>
<propval name='id' type='astring' value='unknown' />
<propval name='address' type='astring' value='unknown' />
</property_group>

<property_group name='startd' type='framework'>
<propval name='duration' type='astring' value='contract' />
</property_group>

<stability value='Unstable' />

<template>
<common_name>
<loctext xml:lang='C'>Oxide Metric Collector</loctext>
</common_name>
<description>
<loctext xml:lang='C'>Server for collecting metrics from the Oxide rack</loctext>
</description>
</template>
</service>

</service_bundle>
File renamed without changes.

0 comments on commit 7f37f2d

Please sign in to comment.