-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Depends on #6894, replaces #6878, fixes #6826 on the server side. Adds a new Dropshot server, `clickhouse-admin-single`, analogous to `clickhouse-admin-keeper` and `clickhouse-admin-server` (which were split off from `clickhouse-admin` in #6837). Its sole purpose is to initialize the single-node ClickHouse database with the current Oximeter schema. We use a single in-memory lock (a `tokio::sync::Mutex`) to serialize initialization requests. Multi-node ClickHouse clusters will need something analogous as a follow-up. --------- Co-authored-by: Andrew J. Stone <[email protected]> Co-authored-by: Karen Cárcamo <[email protected]>
- Loading branch information
1 parent
574b697
commit b4fa875
Showing
22 changed files
with
509 additions
and
27 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
//! Single-node ClickHouse database admin binary. | ||
use anyhow::anyhow; | ||
use camino::Utf8PathBuf; | ||
use clap::Parser; | ||
use omicron_clickhouse_admin::{ClickhouseCli, Config}; | ||
use omicron_common::cmd::fatal; | ||
use omicron_common::cmd::CmdError; | ||
use std::net::{SocketAddr, SocketAddrV6}; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap( | ||
name = "clickhouse-admin-single", | ||
about = "Single-node ClickHouse admin server" | ||
)] | ||
enum Args { | ||
/// Start the single-node ClickHouse admin server | ||
Run { | ||
/// Address on which this server should run | ||
#[clap(long, short = 'a', action)] | ||
http_address: SocketAddrV6, | ||
|
||
/// Path to the server configuration file | ||
#[clap(long, short, action)] | ||
config: Utf8PathBuf, | ||
|
||
/// Address of the ClickHouse single-node database server | ||
#[clap(long, short = 'l', action)] | ||
listen_address: SocketAddrV6, | ||
|
||
/// Path to the clickhouse binary | ||
#[clap(long, short, action)] | ||
binary_path: Utf8PathBuf, | ||
}, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
if let Err(err) = main_impl().await { | ||
fatal(err); | ||
} | ||
} | ||
|
||
async fn main_impl() -> Result<(), CmdError> { | ||
let args = Args::parse(); | ||
|
||
match args { | ||
Args::Run { http_address, config, listen_address, binary_path } => { | ||
let mut config = Config::from_file(&config) | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
config.dropshot.bind_address = SocketAddr::V6(http_address); | ||
let clickhouse_cli = | ||
ClickhouseCli::new(binary_path, listen_address); | ||
|
||
let server = omicron_clickhouse_admin::start_single_admin_server( | ||
clickhouse_cli, | ||
config, | ||
) | ||
.await | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
server.await.map_err(|err| { | ||
CmdError::Failure(anyhow!( | ||
"server failed after starting: {err}" | ||
)) | ||
}) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.