-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cockroach-admin
dropshot server
#5822
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
66ba1b3
add initial cockroach-admin server
jgallagher ccb8d78
add cockroach-admin to self-assembling CRDB zone
jgallagher 83ad31a
add compatibility unit test for `cockroach node status` changes
jgallagher 13a1642
cargo fmt
jgallagher ade1aef
add omicron-rpaths to cockroach-admin
jgallagher 312e11d
sled-agent: make zone_network_setup_install take Ipv6Addr instead of …
jgallagher 7e3ca84
be consistent with crdb socket addr vs ip/port pair
jgallagher 63fd8a1
typo/copy-paste fixes
jgallagher 2023984
Merge remote-tracking branch 'origin/main' into john/cockroach-admin-…
jgallagher b8576aa
Merge remote-tracking branch 'origin/main' into john/cockroach-admin-…
jgallagher 876bcee
cargo fmt
jgallagher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little surprised we need this + the build.rs script. I thought we would have needed this to get access to a copy of postgres - this is normally necessary for Diesel, but is it also necessary to invoke the CLI?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's required by the unit tests that want to spin up cockroach. I could maybe change this to a
dev-dependency
, but then I have to tweak the build script to also only set rpaths when building for tests? Seems fine-ish, although we have thatbit in the copy-paste
build.rs
that wouldn't be valid anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhhh, gotcha, because the unit test scaffolding is making calls with diesel? no objection to this as-is, just was curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess so - I didn't really look into it when I saw the rpath failure in CI.