-
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.
Add
cockroach-admin
dropshot server (#5822)
The goal here is to use this server to run `cockroach node decommission` for expunged cockroach zones. For this initial PR, the only endpoint provided wraps `cockroach node status`; wrapping `decommission` is not as trivial so I figured it should go into a separate PR. There are currently no callers of this service, but stood up an a4x2 and confirmed I could talk to it from the switch zone via `curl`: ``` root@oxz_switch:~# curl http://[fd00:1122:3344:103::3]:32222/node/status {"all_nodes":[{"node_id":"1","address":"[fd00:1122:3344:103::3]:32221","sql_address":"[fd00:1122:3344:103::3]:32221","build":"v22.1.9-dirty","started_at":"2024-05-24T16:47:33.137256Z","updated_at":"2024-05-24T19:01:11.345263Z","locality":"","is_available":true,"is_live":true},{"node_id":"2","address":"[fd00:1122:3344:102::3]:32221","sql_address":"[fd00:1122:3344:102::3]:32221","build":"v22.1.9-dirty","started_at":"2024-05-24T16:41:23.877326Z","updated_at":"2024-05-24T19:01:10.946872Z","locality":"","is_available":true,"is_live":true},{"node_id":"3","address":"[fd00:1122:3344:102::4]:32221","sql_address":"[fd00:1122:3344:102::4]:32221","build":"v22.1.9-dirty","started_at":"2024-05-24T16:41:24.020025Z","updated_at":"2024-05-24T19:01:11.112721Z","locality":"","is_available":true,"is_live":true},{"node_id":"4","address":"[fd00:1122:3344:101::4]:32221","sql_address":"[fd00:1122:3344:101::4]:32221","build":"v22.1.9-dirty","started_at":"2024-05-24T16:41:42.706769Z","updated_at":"2024-05-24T19:01:10.944673Z","locality":"","is_available":true,"is_live":true},{"node_id":"5","address":"[fd00:1122:3344:101::3]:32221","sql_address":"[fd00:1122:3344:101::3]:32221","build":"v22.1.9-dirty","started_at":"2024-05-24T16:41:43.079549Z","updated_at":"2024-05-24T19:01:11.326557Z","locality":"","is_available":true,"is_live":true}]} ```
- Loading branch information
1 parent
2381852
commit 0e3e613
Showing
20 changed files
with
945 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[package] | ||
name = "omicron-cockroach-admin" | ||
version = "0.1.0" | ||
edition = "2021" | ||
license = "MPL-2.0" | ||
|
||
[build-dependencies] | ||
omicron-rpaths.workspace = true | ||
|
||
[dependencies] | ||
anyhow.workspace = true | ||
camino.workspace = true | ||
chrono.workspace = true | ||
clap.workspace = true | ||
csv.workspace = true | ||
dropshot.workspace = true | ||
http.workspace = true | ||
illumos-utils.workspace = true | ||
omicron-common.workspace = true | ||
# See omicron-rpaths for more about the "pq-sys" dependency. | ||
pq-sys = "*" | ||
schemars.workspace = true | ||
slog.workspace = true | ||
slog-async.workspace = true | ||
slog-dtrace.workspace = true | ||
slog-error-chain.workspace = true | ||
serde.workspace = true | ||
thiserror.workspace = true | ||
tokio.workspace = true | ||
toml.workspace = true | ||
|
||
omicron-workspace-hack.workspace = true | ||
|
||
[dev-dependencies] | ||
nexus-test-utils.workspace = true | ||
omicron-test-utils.workspace = true | ||
url.workspace = true | ||
|
||
[lints] | ||
workspace = true |
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,10 @@ | ||
// 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/. | ||
|
||
// See omicron-rpaths for documentation. | ||
// NOTE: This file MUST be kept in sync with the other build.rs files in this | ||
// repository. | ||
fn main() { | ||
omicron_rpaths::configure_default_omicron_rpaths(); | ||
} |
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,79 @@ | ||
// 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/. | ||
|
||
//! Executable program to run the Omicron CockroachDb admin interface (not to be | ||
//! confused with CockroachDb's built-in HTTP API) | ||
use anyhow::anyhow; | ||
use camino::Utf8PathBuf; | ||
use clap::Parser; | ||
use omicron_cockroach_admin::CockroachCli; | ||
use omicron_cockroach_admin::Config; | ||
use omicron_common::cmd::fatal; | ||
use omicron_common::cmd::CmdError; | ||
use std::net::SocketAddr; | ||
use std::net::SocketAddrV6; | ||
|
||
#[derive(Debug, Parser)] | ||
#[clap(name = "cockroach-admin", about = "Omicron CRDB cluster admin server")] | ||
enum Args { | ||
/// Print the OpenAPI Spec document and exit | ||
Openapi, | ||
|
||
/// Start the CRDB admin server | ||
Run { | ||
/// Path to the `cockroach` CLI | ||
#[clap(long, action)] | ||
path_to_cockroach_binary: Utf8PathBuf, | ||
|
||
/// Socket address for a running cockroach server instance | ||
#[clap(long, action)] | ||
cockroach_address: SocketAddrV6, | ||
|
||
/// Address on which this server should run | ||
#[clap(long, action)] | ||
http_address: SocketAddrV6, | ||
|
||
/// Path to the server config file | ||
#[clap(long, action)] | ||
config_file_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::Openapi => omicron_cockroach_admin::run_openapi() | ||
.map_err(|e| CmdError::Failure(anyhow!(e))), | ||
Args::Run { | ||
path_to_cockroach_binary, | ||
cockroach_address, | ||
http_address, | ||
config_file_path, | ||
} => { | ||
let cockroach_cli = | ||
CockroachCli::new(path_to_cockroach_binary, cockroach_address); | ||
let mut config = Config::from_file(&config_file_path) | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
config.dropshot.bind_address = SocketAddr::V6(http_address); | ||
let server = | ||
omicron_cockroach_admin::start_server(cockroach_cli, config) | ||
.await | ||
.map_err(|err| CmdError::Failure(anyhow!(err)))?; | ||
server.await.map_err(|err| { | ||
CmdError::Failure(anyhow!( | ||
"server failed after starting: {err}" | ||
)) | ||
}) | ||
} | ||
} | ||
} |
Oops, something went wrong.