Skip to content

Commit 2ccff45

Browse files
authored
make client-side-versioned APIs versioned (#9295)
Part of #8922. Makes bootstrap-agent, installinator, nexus-internal, and repo-depot versioned such that any incompatible changes are flagged.
1 parent dcf19f8 commit 2ccff45

File tree

36 files changed

+315
-389
lines changed

36 files changed

+315
-389
lines changed

Cargo.lock

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

clients/bootstrap-agent-client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Interface for making API requests to a Bootstrap Agent
66
77
progenitor::generate_api!(
8-
spec = "../../openapi/bootstrap-agent.json",
8+
spec = "../../openapi/bootstrap-agent/bootstrap-agent-1.0.0-127591.json",
99
interface = Positional,
1010
inner_type = slog::Logger,
1111
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {

clients/installinator-client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Interface for installinator to make API requests.
66
77
progenitor::generate_api!(
8-
spec = "../../openapi/installinator.json",
8+
spec = "../../openapi/installinator/installinator-1.0.0-c0ed87.json",
99
interface = Positional,
1010
inner_type = slog::Logger,
1111
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {

clients/nexus-client/src/lib.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//! from within the control plane
77
88
progenitor::generate_api!(
9-
spec = "../../openapi/nexus-internal.json",
9+
spec = "../../openapi/nexus-internal/nexus-internal-1.0.0-6d8ade.json",
1010
interface = Positional,
1111
derives = [schemars::JsonSchema, PartialEq],
1212
inner_type = slog::Logger,
@@ -261,3 +261,13 @@ impl TryFrom<types::ProducerEndpoint>
261261
})
262262
}
263263
}
264+
265+
impl From<nexus_types::external_api::shared::Baseboard> for types::Baseboard {
266+
fn from(value: nexus_types::external_api::shared::Baseboard) -> Self {
267+
types::Baseboard {
268+
part: value.part,
269+
revision: value.revision,
270+
serial: value.serial,
271+
}
272+
}
273+
}

clients/repo-depot-client/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Interface for Sled Agent's Repo Depot to make API requests.
66
77
progenitor::generate_api!(
8-
spec = "../../openapi/repo-depot.json",
8+
spec = "../../openapi/repo-depot/repo-depot-1.0.0-65083f.json",
99
interface = Positional,
1010
inner_type = slog::Logger,
1111
pre_hook = (|log: &slog::Logger, request: &reqwest::Request| {

dev-tools/dropshot-apis/src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ fn all_apis() -> anyhow::Result<ManagedApis> {
5353
let apis = vec![
5454
ManagedApiConfig {
5555
title: "Bootstrap Agent API",
56-
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
56+
versions: Versions::new_versioned(
57+
bootstrap_agent_api::supported_versions(),
58+
),
5759
metadata: ManagedApiMetadata {
5860
description: Some("Per-sled API for setup and teardown"),
5961
contact_url: Some("https://oxide.computer"),
@@ -172,7 +174,9 @@ fn all_apis() -> anyhow::Result<ManagedApis> {
172174
},
173175
ManagedApiConfig {
174176
title: "Installinator API",
175-
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
177+
versions: Versions::new_versioned(
178+
installinator_api::supported_versions(),
179+
),
176180
metadata: ManagedApiMetadata {
177181
description: Some(
178182
"API for installinator to fetch artifacts \
@@ -205,7 +209,9 @@ fn all_apis() -> anyhow::Result<ManagedApis> {
205209
},
206210
ManagedApiConfig {
207211
title: "Nexus internal API",
208-
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
212+
versions: Versions::new_versioned(
213+
nexus_internal_api::supported_versions(),
214+
),
209215
metadata: ManagedApiMetadata {
210216
description: Some("Nexus internal API"),
211217
contact_url: Some("https://oxide.computer"),
@@ -261,7 +267,9 @@ fn all_apis() -> anyhow::Result<ManagedApis> {
261267
},
262268
ManagedApiConfig {
263269
title: "Oxide TUF Repo Depot API",
264-
versions: Versions::new_lockstep(semver::Version::new(0, 0, 1)),
270+
versions: Versions::new_versioned(
271+
repo_depot_api::supported_versions(),
272+
),
265273
metadata: ManagedApiMetadata {
266274
description: Some("API for fetching update artifacts"),
267275
contact_url: Some("https://oxide.computer"),

dev-tools/repo-depot-standalone/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ clap.workspace = true
1616
dropshot.workspace = true
1717
futures.workspace = true
1818
libc.workspace = true
19+
omicron-common.workspace = true
20+
omicron-workspace-hack.workspace = true
1921
oxide-tokio-rt.workspace = true
2022
repo-depot-api.workspace = true
2123
serde_json.workspace = true
@@ -26,7 +28,6 @@ tokio = { workspace = true, features = [ "full" ] }
2628
tokio-util.workspace = true
2729
tufaceous-artifact.workspace = true
2830
update-common.workspace = true
29-
omicron-workspace-hack.workspace = true
3031

3132
[[bin]]
3233
name = "repo-depot-standalone"

dev-tools/repo-depot-standalone/src/main.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,12 @@ impl RepoDepotStandalone {
124124
bind_address: self.listen_addr,
125125
..Default::default()
126126
})
127+
.version_policy(dropshot::VersionPolicy::Dynamic(Box::new(
128+
dropshot::ClientSpecifiesVersionInHeader::new(
129+
omicron_common::api::VERSION_HEADER,
130+
repo_depot_api::latest_version(),
131+
),
132+
)))
127133
.start()
128134
.context("failed to create server")?;
129135

installinator-api/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ workspace = true
1010
[dependencies]
1111
anyhow.workspace = true
1212
dropshot.workspace = true
13+
dropshot-api-manager-types.workspace = true
1314
hyper.workspace = true
1415
omicron-common.workspace = true
1516
omicron-uuid-kinds.workspace = true

installinator-api/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,20 @@ use dropshot::{
1414
HttpResponseHeaders, HttpResponseOk, HttpResponseUpdatedNoContent, Path,
1515
RequestContext, TypedBody,
1616
};
17+
use dropshot_api_manager_types::api_versions;
1718
use hyper::header;
1819
use omicron_uuid_kinds::MupdateUuid;
1920
use schemars::JsonSchema;
2021
use serde::Deserialize;
2122
use tufaceous_artifact::ArtifactHashId;
2223
use update_engine::{NestedSpec, events::EventReport};
2324

25+
api_versions!([
26+
// Do not create new versions of this client-side versioned API.
27+
// https://github.com/oxidecomputer/omicron/issues/9290
28+
(1, INITIAL),
29+
]);
30+
2431
const PROGRESS_REPORT_MAX_BYTES: usize = 4 * 1024 * 1024;
2532

2633
#[derive(Debug, Deserialize, JsonSchema)]

0 commit comments

Comments
 (0)