Skip to content

Commit

Permalink
Create clickhouse-admin service and include it in clickhouse and keep…
Browse files Browse the repository at this point in the history
…er zones
  • Loading branch information
karencfv committed Aug 14, 2024
1 parent ddb45a5 commit f6d2994
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
14 changes: 7 additions & 7 deletions clickhouse-admin/src/bin/clickhouse-admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ enum Args {
Run {
// TODO: take the clickhouse address as an argument
/// Address on which this server should run
#[clap(long, action)]
#[clap(long, short = 'H', action)]
http_address: SocketAddrV6,

/// Path to the server config file
#[clap(long, action)]
config_file_path: Utf8PathBuf,
/// Path to the server configuration file
#[clap(long, short, action)]
config: Utf8PathBuf,
},
}

// TODO: Remove this comment and move config file to smf/clickhouse-admin
// Test with cargo run --bin=clickhouse-admin -- run --http-address [::1]:8888 --config-file-path ./clickhouse-admin/dummy-config.toml
// Test with cargo run --bin=clickhouse-admin -- run -H [::1]:8888 -c ./clickhouse-admin/dummy-config.toml

#[tokio::main]
async fn main() {
Expand All @@ -45,8 +45,8 @@ async fn main_impl() -> Result<(), CmdError> {
let args = Args::parse();

match args {
Args::Run { http_address, config_file_path } => {
let mut config = Config::from_file(&config_file_path)
Args::Run { http_address, config } => {
let mut config = Config::from_file(&config)
.map_err(|err| CmdError::Failure(anyhow!(err)))?;
config.dropshot.bind_address = SocketAddr::V6(http_address);

Expand Down
1 change: 1 addition & 0 deletions common/src/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub const COCKROACH_ADMIN_PORT: u16 = 32222;
pub const CRUCIBLE_PORT: u16 = 32345;
pub const CLICKHOUSE_PORT: u16 = 8123;
pub const CLICKHOUSE_KEEPER_PORT: u16 = 9181;
pub const CLICKHOUSE_ADMIN_PORT: u16 = 8888;
pub const OXIMETER_PORT: u16 = 12223;
pub const DENDRITE_PORT: u16 = 12224;
pub const LLDP_PORT: u16 = 12230;
Expand Down
14 changes: 14 additions & 0 deletions package-manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ source.type = "composite"
source.packages = [
"clickhouse_svc.tar.gz",
"internal-dns-cli.tar.gz",
"omicron-clickhouse-admin.tar.gz",
"zone-setup.tar.gz",
"zone-network-install.tar.gz"
]
Expand All @@ -179,6 +180,7 @@ source.type = "composite"
source.packages = [
"clickhouse_keeper_svc.tar.gz",
"internal-dns-cli.tar.gz",
"omicron-clickhouse-admin.tar.gz",
"zone-setup.tar.gz",
"zone-network-install.tar.gz"
]
Expand All @@ -198,6 +200,18 @@ output.type = "zone"
output.intermediate_only = true
setup_hint = "Run `cargo xtask download clickhouse` to download the necessary binaries"

[package.omicron-clickhouse-admin]
service_name = "clickhouse-admin"
only_for_targets.image = "standard"
source.type = "local"
source.rust.binary_names = ["clickhouse-admin"]
source.rust.release = true
source.paths = [
{ from = "smf/clickhouse-admin", to = "/var/svc/manifest/site/clickhouse-admin" },
]
output.type = "zone"
output.intermediate_only = true

[package.cockroachdb]
service_name = "cockroachdb"
only_for_targets.image = "standard"
Expand Down
50 changes: 48 additions & 2 deletions sled-agent/src/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ use nexus_config::{ConfigDropshotWithTls, DeploymentConfig};
use nexus_sled_agent_shared::inventory::{
OmicronZoneConfig, OmicronZoneType, OmicronZonesConfig, ZoneKind,
};
use omicron_common::address::CLICKHOUSE_ADMIN_PORT;
use omicron_common::address::CLICKHOUSE_KEEPER_PORT;
use omicron_common::address::CLICKHOUSE_PORT;
use omicron_common::address::COCKROACH_PORT;
Expand Down Expand Up @@ -1549,6 +1550,11 @@ impl ServiceManager {

let listen_addr = *underlay_address;
let listen_port = &CLICKHOUSE_PORT.to_string();
let admin_address = SocketAddr::new(
IpAddr::V6(listen_addr),
CLICKHOUSE_ADMIN_PORT,
)
.to_string();

let nw_setup_service = Self::zone_network_setup_install(
Some(&info.underlay_address),
Expand All @@ -1572,12 +1578,29 @@ impl ServiceManager {
.add_property_group(config),
);

let clickhouse_admin_config =
PropertyGroupBuilder::new("config")
// TODO: Add zone ID?
//.add_property("zone_id", "astring", zone_id.to_string())
.add_property(
"clickhouse_address",
"astring",
listen_addr.to_string(),
)
.add_property("http_address", "astring", admin_address);
let clickhouse_admin_service =
ServiceBuilder::new("oxide/clickhouse-admin").add_instance(
ServiceInstanceBuilder::new("default")
.add_property_group(clickhouse_admin_config),
);

let profile = ProfileBuilder::new("omicron")
.add_service(nw_setup_service)
.add_service(disabled_ssh_service)
.add_service(clickhouse_service)
.add_service(dns_service)
.add_service(enabled_dns_client_service);
.add_service(enabled_dns_client_service)
.add_service(clickhouse_admin_service);
profile
.add_to_zone(&self.inner.log, &installed_zone)
.await
Expand All @@ -1602,6 +1625,11 @@ impl ServiceManager {

let listen_addr = *underlay_address;
let listen_port = &CLICKHOUSE_KEEPER_PORT.to_string();
let admin_address = SocketAddr::new(
IpAddr::V6(listen_addr),
CLICKHOUSE_ADMIN_PORT,
)
.to_string();

let nw_setup_service = Self::zone_network_setup_install(
Some(&info.underlay_address),
Expand All @@ -1625,12 +1653,30 @@ impl ServiceManager {
ServiceInstanceBuilder::new("default")
.add_property_group(config),
);

let clickhouse_admin_config =
PropertyGroupBuilder::new("config")
// TODO: Add zone ID?
//.add_property("zone_id", "astring", zone_id.to_string())
.add_property(
"clickhouse_address",
"astring",
listen_addr.to_string(),
)
.add_property("http_address", "astring", admin_address);
let clickhouse_admin_service =
ServiceBuilder::new("oxide/clickhouse-admin").add_instance(
ServiceInstanceBuilder::new("default")
.add_property_group(clickhouse_admin_config),
);

let profile = ProfileBuilder::new("omicron")
.add_service(nw_setup_service)
.add_service(disabled_ssh_service)
.add_service(clickhouse_keeper_service)
.add_service(dns_service)
.add_service(enabled_dns_client_service);
.add_service(enabled_dns_client_service)
.add_service(clickhouse_admin_service);
profile
.add_to_zone(&self.inner.log, &installed_zone)
.await
Expand Down

0 comments on commit f6d2994

Please sign in to comment.