Skip to content

Commit e00aaba

Browse files
authored
[cockroach-admin-types] reorganize per RFD 619 (#9529)
1 parent 0e331a3 commit e00aaba

File tree

24 files changed

+882
-764
lines changed

24 files changed

+882
-764
lines changed

Cargo.lock

Lines changed: 12 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ members = [
2727
"cockroach-admin",
2828
"cockroach-admin/api",
2929
"cockroach-admin/types",
30+
"cockroach-admin/types/versions",
3031
"cockroach-metrics",
3132
"common",
3233
"dev-tools/cert-dev",
@@ -193,6 +194,7 @@ default-members = [
193194
"cockroach-admin",
194195
"cockroach-admin/api",
195196
"cockroach-admin/types",
197+
"cockroach-admin/types/versions",
196198
"cockroach-metrics",
197199
"common",
198200
"dev-tools/cert-dev",
@@ -421,6 +423,7 @@ clickward = { git = "https://github.com/oxidecomputer/clickward", rev = "e3d9a1c
421423
cockroach-admin-api = { path = "cockroach-admin/api" }
422424
cockroach-admin-client = { path = "clients/cockroach-admin-client" }
423425
cockroach-admin-types = { path = "cockroach-admin/types" }
426+
cockroach-admin-types-versions = { path = "cockroach-admin/types/versions" }
424427
colored = "2.1"
425428
const_format = "0.2.34"
426429
cookie = "0.18"

cockroach-admin/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ chrono.workspace = true
1515
clap.workspace = true
1616
cockroach-admin-api.workspace = true
1717
cockroach-admin-types.workspace = true
18+
cockroach-admin-types-versions.workspace = true
1819
csv.workspace = true
1920
dropshot.workspace = true
2021
http.workspace = true

cockroach-admin/api/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,10 @@ license = "MPL-2.0"
88
workspace = true
99

1010
[dependencies]
11-
cockroach-admin-types.workspace = true
11+
cockroach-admin-types-versions.workspace = true
1212
dropshot.workspace = true
1313
dropshot-api-manager-types.workspace = true
1414
http.workspace = true
1515
omicron-common.workspace = true
16-
omicron-uuid-kinds.workspace = true
1716
omicron-workspace-hack.workspace = true
18-
schemars.workspace = true
1917
semver.workspace = true
20-
serde.workspace = true

cockroach-admin/api/src/lib.rs

Lines changed: 5 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,12 @@
22
// License, v. 2.0. If a copy of the MPL was not distributed with this
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

5-
use cockroach_admin_types::{NodeDecommission, NodeStatus};
5+
use cockroach_admin_types_versions::latest;
66
use dropshot::{
77
HttpError, HttpResponseOk, HttpResponseUpdatedNoContent, RequestContext,
88
TypedBody,
99
};
1010
use dropshot_api_manager_types::api_versions;
11-
use omicron_uuid_kinds::OmicronZoneUuid;
12-
use schemars::JsonSchema;
13-
use serde::{Deserialize, Serialize};
1411

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

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

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

9491
/// Proxy to CockroachDB's /_status/vars endpoint
9592
//
@@ -114,35 +111,3 @@ pub trait CockroachAdminApi {
114111
rqctx: RequestContext<Self::Context>,
115112
) -> Result<HttpResponseOk<String>, HttpError>;
116113
}
117-
118-
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
119-
#[serde(rename_all = "snake_case")]
120-
pub struct ClusterNodeStatus {
121-
pub all_nodes: Vec<NodeStatus>,
122-
}
123-
124-
/// CockroachDB Node ID
125-
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
126-
#[serde(rename_all = "snake_case")]
127-
pub struct LocalNodeId {
128-
/// The ID of this Omicron zone.
129-
///
130-
/// This is included to ensure correctness even if a socket address on a
131-
/// sled is reused for a different zone; if our caller is trying to
132-
/// determine the node ID for a particular Omicron CockroachDB zone, they'll
133-
/// contact us by socket address. We include our zone ID in the response for
134-
/// their confirmation that we are the zone they intended to contact.
135-
pub zone_id: OmicronZoneUuid,
136-
// CockroachDB node IDs are integers, in practice, but our use of them is as
137-
// input and output to the `cockroach` CLI. We use a string which is a bit
138-
// more natural (no need to parse CLI output or stringify an ID to send it
139-
// as input) and leaves open the door for the format to change in the
140-
// future.
141-
pub node_id: String,
142-
}
143-
144-
#[derive(Debug, Clone, PartialEq, Eq, Deserialize, Serialize, JsonSchema)]
145-
#[serde(rename_all = "snake_case")]
146-
pub struct NodeId {
147-
pub node_id: String,
148-
}

cockroach-admin/src/cockroach_cli.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
use camino::Utf8PathBuf;
6-
use cockroach_admin_types::NodeDecommission;
7-
use cockroach_admin_types::NodeStatus;
8-
use cockroach_admin_types::ParseError;
6+
use cockroach_admin_types::node::{NodeDecommission, NodeStatus, ParseError};
97
use dropshot::HttpError;
108
use illumos_utils::ExecutionError;
119
use illumos_utils::output_to_exec_error;
@@ -362,7 +360,7 @@ mod tests {
362360
use super::*;
363361
use camino_tempfile::Utf8TempDir;
364362
use chrono::Utc;
365-
use cockroach_admin_types::NodeMembership;
363+
use cockroach_admin_types::node::NodeMembership;
366364
use nexus_test_utils::db::TestDatabase;
367365
use omicron_test_utils::dev;
368366
use omicron_test_utils::dev::poll;

cockroach-admin/src/http_entrypoints.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
44

55
use crate::context::ServerContext;
6-
use cockroach_admin_api::*;
7-
use cockroach_admin_types::NodeDecommission;
6+
use cockroach_admin_api::{CockroachAdminApi, cockroach_admin_api_mod};
7+
use cockroach_admin_types::node::{
8+
ClusterNodeStatus, LocalNodeId, NodeDecommission, NodeId,
9+
};
810
use dropshot::HttpError;
911
use dropshot::HttpResponseOk;
1012
use dropshot::HttpResponseUpdatedNoContent;

cockroach-admin/types/Cargo.toml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ license = "MPL-2.0"
88
workspace = true
99

1010
[dependencies]
11-
chrono.workspace = true
12-
csv.workspace = true
13-
omicron-common.workspace = true
11+
cockroach-admin-types-versions.workspace = true
1412
omicron-workspace-hack.workspace = true
15-
schemars.workspace = true
1613
serde.workspace = true
17-
thiserror.workspace = true
18-
19-
[dev-dependencies]
20-
proptest.workspace = true
21-
test-strategy.workspace = true

0 commit comments

Comments
 (0)