Skip to content

Commit e76962a

Browse files
authored
[1/n] create a nexus-lockstep service (#8983)
First step of #8902. It's enough work to get Nexus to stand up another HTTP service that this is worth its own PR ahead of moving APIs out of nexus-internal and into nexus-lockstep.
1 parent 544f608 commit e76962a

File tree

71 files changed

+9704
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+9704
-165
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ members = [
1616
"clients/gateway-client",
1717
"clients/installinator-client",
1818
"clients/nexus-client",
19+
"clients/nexus-lockstep-client",
1920
"clients/ntp-admin-client",
2021
"clients/oxide-client",
2122
"clients/oximeter-client",
@@ -89,6 +90,7 @@ members = [
8990
"nexus/external-api",
9091
"nexus/internal-api",
9192
"nexus/inventory",
93+
"nexus/lockstep-api",
9294
"nexus/macros-common",
9395
"nexus/metrics-producer-gc",
9496
"nexus/mgs-updates",
@@ -174,6 +176,7 @@ default-members = [
174176
"clients/gateway-client",
175177
"clients/installinator-client",
176178
"clients/nexus-client",
179+
"clients/nexus-lockstep-client",
177180
"clients/ntp-admin-client",
178181
"clients/oxide-client",
179182
"clients/oximeter-client",
@@ -249,6 +252,7 @@ default-members = [
249252
"nexus/external-api",
250253
"nexus/internal-api",
251254
"nexus/inventory",
255+
"nexus/lockstep-api",
252256
"nexus/macros-common",
253257
"nexus/metrics-producer-gc",
254258
"nexus/mgs-updates",
@@ -545,6 +549,8 @@ nexus-defaults = { path = "nexus/defaults" }
545549
nexus-external-api = { path = "nexus/external-api" }
546550
nexus-inventory = { path = "nexus/inventory" }
547551
nexus-internal-api = { path = "nexus/internal-api" }
552+
nexus-lockstep-api = { path = "nexus/lockstep-api" }
553+
nexus-lockstep-client = { path = "clients/nexus-lockstep-client" }
548554
nexus-macros-common = { path = "nexus/macros-common" }
549555
nexus-metrics-producer-gc = { path = "nexus/metrics-producer-gc" }
550556
nexus-mgs-updates = { path = "nexus/mgs-updates" }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "nexus-lockstep-client"
3+
version = "0.1.0"
4+
edition = "2024"
5+
license = "MPL-2.0"
6+
7+
[lints]
8+
workspace = true
9+
10+
[dependencies]
11+
chrono.workspace = true
12+
futures.workspace = true
13+
omicron-workspace-hack.workspace = true
14+
progenitor.workspace = true
15+
regress.workspace = true
16+
reqwest.workspace = true
17+
schemars.workspace = true
18+
serde.workspace = true
19+
slog.workspace = true
20+
uuid.workspace = true
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// This Source Code Form is subject to the terms of the Mozilla Public
2+
// License, v. 2.0. If a copy of the MPL was not distributed with this
3+
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4+
5+
//! Interface for making API requests to the Oxide control plane at large from
6+
//! callers that update in lockstep with Nexus itself (e.g. rack initialization,
7+
//! tests and debugging)
8+
9+
progenitor::generate_api!(
10+
spec = "../../openapi/nexus-lockstep.json",
11+
interface = Positional,
12+
derives = [schemars::JsonSchema],
13+
inner_type = slog::Logger,
14+
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {
15+
slog::debug!(log, "client request";
16+
"method" => %request.method(),
17+
"uri" => %request.url(),
18+
"body" => ?&request.body(),
19+
);
20+
}),
21+
post_hook = (|log: &slog::Logger, result: &Result<_, _>| {
22+
slog::debug!(log, "client response"; "result" => ?result);
23+
}),
24+
);

common/src/address.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub const BOOTSTRAP_ARTIFACT_PORT: u16 = 12227;
5353
pub const CRUCIBLE_PANTRY_PORT: u16 = 17000;
5454
pub const TFPORTD_PORT: u16 = 12231;
5555
pub const NEXUS_INTERNAL_PORT: u16 = 12221;
56+
pub const NEXUS_LOCKSTEP_PORT: u16 = 12232;
5657

5758
/// The port on which Nexus exposes its external API on the underlay network.
5859
///

dev-tools/ls-apis/api-manifest.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,15 @@ server_package_name = "nexus-internal-api"
339339
versioned_how = "client"
340340
versioned_how_reason = "Circular dependencies between Nexus and other services"
341341

342+
[[apis]]
343+
client_package_name = "nexus-lockstep-client"
344+
label = "Nexus Internal Lockstep API"
345+
server_package_name = "nexus-lockstep-api"
346+
# nexus-lockstep-client has to be client-versioned because it's got a cyclic
347+
# dependency with sled-agent-client, which is server-versioned.
348+
versioned_how = "client"
349+
versioned_how_reason = "Circular dependencies between Nexus and other services"
350+
342351
[[apis]]
343352
client_package_name = "oxide-client"
344353
label = "External API"

dev-tools/ls-apis/tests/api_dependencies.out

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Nexus Internal API (client: nexus-client)
7070
consumed by: oximeter-collector (omicron/oximeter/collector) via 1 path
7171
consumed by: propolis-server (propolis/bin/propolis-server) via 3 paths
7272

73+
Nexus Internal Lockstep API (client: nexus-lockstep-client)
74+
7375
NTP Admin (client: ntp-admin-client)
7476
consumed by: omicron-nexus (omicron/nexus) via 2 paths
7577
consumed by: omicron-sled-agent (omicron/sled-agent) via 2 paths

dev-tools/omicron-dev/src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ impl RunAllArgs {
108108
"omicron-dev: nexus internal API: {:?}",
109109
cptestctx.server.get_http_server_internal_address().await,
110110
);
111+
println!(
112+
"omicron-dev: nexus lockstep API: {:?}",
113+
cptestctx.server.get_http_server_lockstep_address().await,
114+
);
111115
println!(
112116
"omicron-dev: cockroachdb pid: {}",
113117
cptestctx.database.pid(),

dev-tools/openapi-manager/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,16 @@ cockroach-admin-api.workspace = true
1818
debug-ignore.workspace = true
1919
dns-server-api.workspace = true
2020
dropshot.workspace = true
21-
hex.workspace = true
2221
fs-err.workspace = true
2322
gateway-api.workspace = true
23+
hex.workspace = true
2424
indent_write.workspace = true
2525
installinator-api.workspace = true
2626
itertools.workspace = true
27+
newtype_derive.workspace = true
2728
nexus-external-api.workspace = true
2829
nexus-internal-api.workspace = true
29-
newtype_derive.workspace = true
30+
nexus-lockstep-api.workspace = true
3031
ntp-admin-api.workspace = true
3132
omicron-workspace-hack.workspace = true
3233
openapi-lint.workspace = true
@@ -41,9 +42,9 @@ sha2.workspace = true
4142
similar.workspace = true
4243
sled-agent-api.workspace = true
4344
slog-error-chain.workspace = true
45+
supports-color.workspace = true
4446
textwrap.workspace = true
4547
thiserror.workspace = true
46-
supports-color.workspace = true
4748
wicketd-api.workspace = true
4849

4950
[dev-dependencies]

dev-tools/openapi-manager/src/omicron.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use gateway_api::gateway_api_mod;
1313
use installinator_api::installinator_api_mod;
1414
use nexus_external_api::nexus_external_api_mod;
1515
use nexus_internal_api::nexus_internal_api_mod;
16+
use nexus_lockstep_api::nexus_lockstep_api_mod;
1617
use ntp_admin_api::ntp_admin_api_mod;
1718
use oximeter_api::oximeter_api_mod;
1819
use repo_depot_api::repo_depot_api_mod;
@@ -136,6 +137,15 @@ pub fn all_apis() -> Vec<ManagedApiConfig> {
136137
ident: "nexus-internal",
137138
extra_validation: None,
138139
},
140+
ManagedApiConfig {
141+
title: "Nexus lockstep API",
142+
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
143+
description: "Nexus lockstep internal API",
144+
boundary: ApiBoundary::Internal,
145+
api_description: nexus_lockstep_api_mod::stub_api_description,
146+
ident: "nexus-lockstep",
147+
extra_validation: None,
148+
},
139149
ManagedApiConfig {
140150
title: "NTP Admin API",
141151
versions: Versions::new_versioned(

0 commit comments

Comments
 (0)