Skip to content

Commit

Permalink
[wicketd] convert wicket -> wicketd API to a trait (#6078)
Browse files Browse the repository at this point in the history
Move the wicketd API to a new `wicketd-api` crate, and use that
everywhere.

I had to do a few more changes along the way:

1. In the interest of keeping the API crate itself small, I moved a lot of the
underlying types to wicket-common. An example is the update-engine spec
for preflight checks -- that shouldn't really live in the API crate.
2. As a followup I also used those types in the API rather than relying
on generic specs. This made the JSON a bit bigger but resulted in a nice
cleanup on the wicket end, since the types can be shared.
3. With wicketd-api in its own crate, two copies of `SpIdentifier` and all of the
other types around that got way out of hand. Luckily, addressing that
was quite simple -- just using the gateway-client copy of `SpIdentifier`
everywhere. This means a few more `replace`s, but I think the value of
never having to see an `SpIdentifier2` is quite high.

The wicketd API being difficult to update was a key motivation behind me
starting work on API traits, so it's nice to see that come to fruition.
  • Loading branch information
sunshowers authored Jul 16, 2024
1 parent 0ac003d commit 4cde53b
Show file tree
Hide file tree
Showing 44 changed files with 2,908 additions and 1,774 deletions.
23 changes: 23 additions & 0 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 @@ -88,6 +88,7 @@ members = [
"wicket-dbg",
"wicket",
"wicketd",
"wicketd-api",
"workspace-hack",
"zone-setup",
]
Expand Down Expand Up @@ -184,6 +185,7 @@ default-members = [
"wicket-dbg",
"wicket",
"wicketd",
"wicketd-api",
"workspace-hack",
"zone-setup",
]
Expand Down Expand Up @@ -533,6 +535,7 @@ walkdir = "2.5"
whoami = "1.5"
wicket = { path = "wicket" }
wicket-common = { path = "wicket-common" }
wicketd-api = { path = "wicketd-api" }
wicketd-client = { path = "clients/wicketd-client" }
zeroize = { version = "1.7.0", features = ["zeroize_derive", "std"] }
zip = { version = "0.6.6", default-features = false, features = ["deflate","bzip2"] }
Expand Down
34 changes: 21 additions & 13 deletions clients/wicketd-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,11 @@ progenitor::generate_api!(
RackNetworkConfigV2 = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RackOperationStatus = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RackResetId = { derives = [PartialEq, Eq, PartialOrd, Ord] },
RackV1Inventory = { derives = [PartialEq, Eq, PartialOrd, Ord]},
RotImageDetails = { derives = [PartialEq, Eq, PartialOrd, Ord]},
RotInventory = { derives = [PartialEq, Eq, PartialOrd, Ord]},
RotSlot = { derives = [PartialEq, Eq, PartialOrd, Ord]},
RotState = { derives = [PartialEq, Eq, PartialOrd, Ord]},
SpComponentCaboose = { derives = [PartialEq, Eq, PartialOrd, Ord] },
SpComponentInfo = { derives = [PartialEq, Eq, PartialOrd, Ord]},
SpIgnition = { derives = [PartialEq, Eq, PartialOrd, Ord]},
SpIgnitionSystemType= { derives = [PartialEq, Eq, PartialOrd, Ord]},
SpInventory = { derives = [PartialEq, Eq, PartialOrd, Ord]},
SpState = { derives = [PartialEq, Eq, PartialOrd, Ord] },
StartUpdateOptions = { derives = [Default]},
UplinkConfig = { derives = [PartialEq, Eq, PartialOrd, Ord] },
},
replace = {
AbortUpdateOptions = wicket_common::rack_update::AbortUpdateOptions,
AllowedSourceIps = omicron_common::api::internal::shared::AllowedSourceIps,
Baseboard = sled_hardware_types::Baseboard,
BgpAuthKey = wicket_common::rack_setup::BgpAuthKey,
Expand All @@ -52,9 +42,11 @@ progenitor::generate_api!(
BgpPeerAuthKind = wicket_common::rack_setup::BgpPeerAuthKind,
BgpPeerConfig = omicron_common::api::internal::shared::BgpPeerConfig,
BootstrapSledDescription = wicket_common::rack_setup::BootstrapSledDescription,
ClearUpdateStateOptions = wicket_common::rack_update::ClearUpdateStateOptions,
ClearUpdateStateResponse = wicket_common::rack_update::ClearUpdateStateResponse,
CurrentRssUserConfigInsensitive = wicket_common::rack_setup::CurrentRssUserConfigInsensitive,
Duration = std::time::Duration,
EventReportForUplinkPreflightCheckSpec = wicket_common::preflight_check::EventReport,
EventReportForWicketdEngineSpec = wicket_common::update_events::EventReport,
GetBgpAuthKeyInfoResponse = wicket_common::rack_setup::GetBgpAuthKeyInfoResponse,
ImportExportPolicy = omicron_common::api::internal::shared::ImportExportPolicy,
Expand All @@ -67,15 +59,31 @@ progenitor::generate_api!(
PortSpeed = omicron_common::api::internal::shared::PortSpeed,
ProgressEventForGenericSpec = update_engine::events::ProgressEvent<update_engine::NestedSpec>,
ProgressEventForInstallinatorSpec = installinator_common::ProgressEvent,
ProgressEventForUplinkPreflightSpec = wicket_common::preflight_check::ProgressEvent,
ProgressEventForWicketdEngineSpec = wicket_common::update_events::ProgressEvent,
PutRssUserConfigInsensitive = wicket_common::rack_setup::PutRssUserConfigInsensitive,
RackV1Inventory = wicket_common::inventory::RackV1Inventory,
RotInventory = wicket_common::inventory::RotInventory,
RotSlot = wicket_common::inventory::RotSlot,
RotState = wicket_common::inventory::RotState,
RouteConfig = omicron_common::api::internal::shared::RouteConfig,
SpIdentifier = wicket_common::rack_update::SpIdentifier,
SpType = wicket_common::rack_update::SpType,
SpComponentCaboose = wicket_common::inventory::SpComponentCaboose,
SpComponentInfo = wicket_common::inventory::SpComponentInfo,
SpIdentifier = wicket_common::inventory::SpIdentifier,
SpIgnition = wicket_common::inventory::SpIgnition,
SpIgnitionSystemType = wicket_common::inventory::SpIgnitionSystemType,
SpInventory = wicket_common::inventory::SpInventory,
SpState = wicket_common::inventory::SpState,
SpType = wicket_common::inventory::SpType,
StartUpdateOptions = wicket_common::rack_update::StartUpdateOptions,
StepEventForGenericSpec = update_engine::events::StepEvent<update_engine::NestedSpec>,
StepEventForUplinkPreflightSpec = wicket_common::preflight_check::StepEvent,
StepEventForInstallinatorSpec = installinator_common::StepEvent,
StepEventForWicketdEngineSpec = wicket_common::update_events::StepEvent,
SwitchLocation = omicron_common::api::internal::shared::SwitchLocation,
UpdateSimulatedResult = wicket_common::rack_update::UpdateSimulatedResult,
UpdateTestError = wicket_common::rack_update::UpdateTestError,
UplinkPreflightStepId = wicket_common::preflight_check::UplinkPreflightStepId,
UserSpecifiedBgpPeerConfig = wicket_common::rack_setup::UserSpecifiedBgpPeerConfig,
UserSpecifiedImportExportPolicy = wicket_common::rack_setup::UserSpecifiedImportExportPolicy,
UserSpecifiedPortConfig = wicket_common::rack_setup::UserSpecifiedPortConfig,
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 @@ -25,3 +25,4 @@ owo-colors.workspace = true
serde_json.workspace = true
similar.workspace = true
supports-color.workspace = true
wicketd-api.workspace = true
9 changes: 9 additions & 0 deletions dev-tools/openapi-manager/src/spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,15 @@ pub fn all_apis() -> Vec<ApiSpec> {
filename: "nexus-internal.json",
extra_validation: None,
},
ApiSpec {
title: "Oxide Technician Port Control Service",
version: "0.0.1",
description: "API for use by the technician port TUI: wicket",
boundary: ApiBoundary::Internal,
api_description: wicketd_api::wicketd_api_mod::stub_api_description,
filename: "wicketd.json",
extra_validation: None,
},
// Add your APIs here! Please keep this list sorted by filename.
]
}
Expand Down
Loading

0 comments on commit 4cde53b

Please sign in to comment.