Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ members = [
"cockroach-admin",
"cockroach-admin/api",
"cockroach-admin/types",
"cockroach-admin/types/versions",
"cockroach-metrics",
"common",
"dev-tools/cert-dev",
Expand Down Expand Up @@ -192,6 +193,7 @@ default-members = [
"cockroach-admin",
"cockroach-admin/api",
"cockroach-admin/types",
"cockroach-admin/types/versions",
"cockroach-metrics",
"common",
"dev-tools/cert-dev",
Expand Down Expand Up @@ -419,6 +421,7 @@ clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "e3d9a1c
cockroach-admin-api = { path = "cockroach-admin/api" }
cockroach-admin-client = { path = "clients/cockroach-admin-client" }
cockroach-admin-types = { path = "cockroach-admin/types" }
cockroach-admin-types-versions = { path = "cockroach-admin/types/versions" }
colored = "2.1"
const_format = "0.2.34"
cookie = "0.18"
Expand Down
1 change: 1 addition & 0 deletions cockroach-admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ chrono.workspace = true
clap.workspace = true
cockroach-admin-api.workspace = true
cockroach-admin-types.workspace = true
cockroach-admin-types-versions.workspace = true
csv.workspace = true
dropshot.workspace = true
http.workspace = true
Expand Down
5 changes: 1 addition & 4 deletions cockroach-admin/api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,10 @@ license = "MPL-2.0"
workspace = true

[dependencies]
cockroach-admin-types.workspace = true
cockroach-admin-types-versions.workspace = true
dropshot.workspace = true
dropshot-api-manager-types.workspace = true
http.workspace = true
omicron-common.workspace = true
omicron-uuid-kinds.workspace = true
omicron-workspace-hack.workspace = true
schemars.workspace = true
semver.workspace = true
serde.workspace = true
45 changes: 5 additions & 40 deletions cockroach-admin/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@
// 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/.

use cockroach_admin_types::{NodeDecommission, NodeStatus};
use cockroach_admin_types_versions::latest;
use dropshot::{
HttpError, HttpResponseOk, HttpResponseUpdatedNoContent, RequestContext,
TypedBody,
};
use dropshot_api_manager_types::api_versions;
use omicron_uuid_kinds::OmicronZoneUuid;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

api_versions!([
// WHEN CHANGING THE API (part 1 of 2):
Expand Down Expand Up @@ -70,7 +67,7 @@ pub trait CockroachAdminApi {
}]
async fn node_status(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<ClusterNodeStatus>, HttpError>;
) -> Result<HttpResponseOk<latest::node::ClusterNodeStatus>, HttpError>;

/// Get the CockroachDB node ID of the local cockroach instance.
#[endpoint {
Expand All @@ -79,7 +76,7 @@ pub trait CockroachAdminApi {
}]
async fn local_node_id(
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<LocalNodeId>, HttpError>;
) -> Result<HttpResponseOk<latest::node::LocalNodeId>, HttpError>;

/// Decommission a node from the CRDB cluster.
#[endpoint {
Expand All @@ -88,8 +85,8 @@ pub trait CockroachAdminApi {
}]
async fn node_decommission(
rqctx: RequestContext<Self::Context>,
body: TypedBody<NodeId>,
) -> Result<HttpResponseOk<NodeDecommission>, HttpError>;
body: TypedBody<latest::node::NodeId>,
) -> Result<HttpResponseOk<latest::node::NodeDecommission>, HttpError>;

/// Proxy to CockroachDB's /_status/vars endpoint
//
Expand All @@ -114,35 +111,3 @@ pub trait CockroachAdminApi {
rqctx: RequestContext<Self::Context>,
) -> Result<HttpResponseOk<String>, HttpError>;
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct ClusterNodeStatus {
pub all_nodes: Vec<NodeStatus>,
}

/// CockroachDB Node ID
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct LocalNodeId {
/// The ID of this Omicron zone.
///
/// This is included to ensure correctness even if a socket address on a
/// sled is reused for a different zone; if our caller is trying to
/// determine the node ID for a particular Omicron CockroachDB zone, they'll
/// contact us by socket address. We include our zone ID in the response for
/// their confirmation that we are the zone they intended to contact.
pub zone_id: OmicronZoneUuid,
// CockroachDB node IDs are integers, in practice, but our use of them is as
// input and output to the `cockroach` CLI. We use a string which is a bit
// more natural (no need to parse CLI output or stringify an ID to send it
// as input) and leaves open the door for the format to change in the
// future.
pub node_id: String,
}

#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub struct NodeId {
pub node_id: String,
}
6 changes: 2 additions & 4 deletions cockroach-admin/src/cockroach_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use camino::Utf8PathBuf;
use cockroach_admin_types::NodeDecommission;
use cockroach_admin_types::NodeStatus;
use cockroach_admin_types::ParseError;
use cockroach_admin_types::node::{NodeDecommission, NodeStatus, ParseError};
use dropshot::HttpError;
use illumos_utils::ExecutionError;
use illumos_utils::output_to_exec_error;
Expand Down Expand Up @@ -362,7 +360,7 @@ mod tests {
use super::*;
use camino_tempfile::Utf8TempDir;
use chrono::Utc;
use cockroach_admin_types::NodeMembership;
use cockroach_admin_types::node::NodeMembership;
use nexus_test_utils::db::TestDatabase;
use omicron_test_utils::dev;
use omicron_test_utils::dev::poll;
Expand Down
6 changes: 4 additions & 2 deletions cockroach-admin/src/http_entrypoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::context::ServerContext;
use cockroach_admin_api::*;
use cockroach_admin_types::NodeDecommission;
use cockroach_admin_api::{CockroachAdminApi, cockroach_admin_api_mod};
use cockroach_admin_types::node::{
ClusterNodeStatus, LocalNodeId, NodeDecommission, NodeId,
};
use dropshot::HttpError;
use dropshot::HttpResponseOk;
use dropshot::HttpResponseUpdatedNoContent;
Expand Down
10 changes: 1 addition & 9 deletions cockroach-admin/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,6 @@ license = "MPL-2.0"
workspace = true

[dependencies]
chrono.workspace = true
csv.workspace = true
omicron-common.workspace = true
cockroach-admin-types-versions.workspace = true
omicron-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true
thiserror.workspace = true

[dev-dependencies]
proptest.workspace = true
test-strategy.workspace = true
Loading
Loading