Skip to content

Commit

Permalink
[gateway] turn API into a trait (#6145)
Browse files Browse the repository at this point in the history
Somewhat large, but with no functional changes -- this is pure code movement.

In a few spots I had to move away from `From` impls, so that gateway-types does
not depend on gateway-sp-comms. I think those changes are for the best.

As a bonus, sp-sim no longer has to depend on omicron-gateway, cutting down the
number of build units for it from 600 to 468. That's a really nice improvement.
  • Loading branch information
sunshowers authored Jul 26, 2024
1 parent 4cb3a23 commit f5ab051
Show file tree
Hide file tree
Showing 36 changed files with 2,532 additions and 2,280 deletions.
36 changes: 33 additions & 3 deletions Cargo.lock

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

10 changes: 8 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ members = [
"dns-server",
"dns-server-api",
"end-to-end-tests",
"gateway",
"gateway-api",
"gateway-cli",
"gateway-test-utils",
"gateway",
"gateway-types",
"illumos-utils",
"installinator-api",
"installinator-common",
Expand Down Expand Up @@ -133,9 +135,11 @@ default-members = [
"dns-server-api",
# Do not include end-to-end-tests in the list of default members, as its
# tests only work on a deployed control plane.
"gateway",
"gateway-api",
"gateway-cli",
"gateway-test-utils",
"gateway",
"gateway-types",
"illumos-utils",
"installinator-api",
"installinator-common",
Expand Down Expand Up @@ -315,10 +319,12 @@ flume = "0.11.0"
foreign-types = "0.3.2"
fs-err = "2.11.0"
futures = "0.3.30"
gateway-api = { path = "gateway-api" }
gateway-client = { path = "clients/gateway-client" }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "c85a4ca043aaa389df12aac5348d8a3feda28762", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "c85a4ca043aaa389df12aac5348d8a3feda28762" }
gateway-test-utils = { path = "gateway-test-utils" }
gateway-types = { path = "gateway-types" }
gethostname = "0.4.3"
glob = "0.3.1"
guppy = "0.17.5"
Expand Down
11 changes: 11 additions & 0 deletions clients/gateway-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,17 @@ pub use gateway_messages::SpComponent;
// If the format of inventory data desired by wicket or nexus changes such that
// it is no longer useful to directly expose the JsonSchema types, we can go
// back to reusing `omicron_common`.
//
// As another alternative, since the `derives` and `patch` directives were
// introduced, these types have moved to living in gateway-types. This means
// that we can choose to use `replace` on them. That hasn't felt necessary so
// far, but it's an option if it becomes desirable in the future. (One reason
// to do that might be that currently, `nexus-types` depends on
// `gateway-client`. Generally we expect the `-client` layer to depend on the
// `-types` layer to avoid a circular dependency, and we've had to resolve a
// rather thorny one between Nexus and sled-agent. But Nexus and sled-agent
// call into each other. Since `gateway` is a lower-level service and never
// calls into Nexus, the current scheme is okay.)
progenitor::generate_api!(
spec = "../../openapi/gateway.json",
inner_type = slog::Logger,
Expand Down
1 change: 1 addition & 0 deletions dev-tools/openapi-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ clap.workspace = true
dns-server-api.workspace = true
dropshot.workspace = true
fs-err.workspace = true
gateway-api.workspace = true
indent_write.workspace = true
installinator-api.workspace = true
nexus-internal-api.workspace = true
Expand Down
23 changes: 17 additions & 6 deletions dev-tools/openapi-manager/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,36 @@ use openapiv3::OpenAPI;
/// All APIs managed by openapi-manager.
pub fn all_apis() -> Vec<ApiSpec> {
vec![
ApiSpec {
title: "Bootstrap Agent API",
version: "0.0.1",
description: "Per-sled API for setup and teardown",
boundary: ApiBoundary::Internal,
api_description:
bootstrap_agent_api::bootstrap_agent_api_mod::stub_api_description,
filename: "bootstrap-agent.json",
extra_validation: None,
},
ApiSpec {
title: "CockroachDB Cluster Admin API",
version: "0.0.1",
description: "API for interacting with the Oxide control plane's \
CockroachDB cluster",
description: "API for interacting with the Oxide \
control plane's CockroachDB cluster",
boundary: ApiBoundary::Internal,
api_description:
cockroach_admin_api::cockroach_admin_api_mod::stub_api_description,
filename: "cockroach-admin.json",
extra_validation: None,
},
ApiSpec {
title: "Bootstrap Agent API",
title: "Oxide Management Gateway Service API",
version: "0.0.1",
description: "Per-sled API for setup and teardown",
description: "API for interacting with the Oxide \
control plane's gateway service",
boundary: ApiBoundary::Internal,
api_description:
bootstrap_agent_api::bootstrap_agent_api_mod::stub_api_description,
filename: "bootstrap-agent.json",
gateway_api::gateway_api_mod::stub_api_description,
filename: "gateway.json",
extra_validation: None,
},
ApiSpec {
Expand Down
18 changes: 18 additions & 0 deletions gateway-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "gateway-api"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"

[lints]
workspace = true

[dependencies]
dropshot.workspace = true
gateway-types.workspace = true
omicron-common.workspace = true
omicron-uuid-kinds.workspace = true
omicron-workspace-hack.workspace = true
schemars.workspace = true
serde.workspace = true
uuid.workspace = true
Loading

0 comments on commit f5ab051

Please sign in to comment.