Skip to content

Commit a6b2461

Browse files
authored
Take TypedUuids out of the external API (#8910)
I noticed in #8803 (comment) that there are some typed UUIDs leaking into the external API. As I said in the comment, I don't think this information is likely to be useful for clients because we don't actually use it in any of the request body types, only the responses. I don't think this change hurts correctness in our code because the conversion to generic UUID usually happens right at the end of request handling, when models are converted to views for response serialization. However, there are a couple of spots where the struct is used a little earlier in the process (see how the affinity datastore functions return view structs) or is shared with internal API code, so there may be a tiny risk to correctness.
1 parent f3e71b0 commit a6b2461

File tree

6 files changed

+28
-37
lines changed

6 files changed

+28
-37
lines changed

common/src/api/external/mod.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,12 @@ pub enum AffinityGroupMember {
13011301
///
13021302
/// Instances can belong to up to 16 affinity groups.
13031303
// See: INSTANCE_MAX_AFFINITY_GROUPS
1304-
Instance { id: InstanceUuid, name: Name, run_state: InstanceState },
1304+
Instance {
1305+
#[schemars(with = "Uuid")]
1306+
id: InstanceUuid,
1307+
name: Name,
1308+
run_state: InstanceState,
1309+
},
13051310
}
13061311

13071312
impl SimpleIdentityOrName for AffinityGroupMember {
@@ -1332,7 +1337,12 @@ pub enum AntiAffinityGroupMember {
13321337
///
13331338
/// Instances can belong to up to 16 anti-affinity groups.
13341339
// See: INSTANCE_MAX_ANTI_AFFINITY_GROUPS
1335-
Instance { id: InstanceUuid, name: Name, run_state: InstanceState },
1340+
Instance {
1341+
#[schemars(with = "Uuid")]
1342+
id: InstanceUuid,
1343+
name: Name,
1344+
run_state: InstanceState,
1345+
},
13361346
}
13371347

13381348
impl SimpleIdentityOrName for AntiAffinityGroupMember {

dev-tools/omdb/src/bin/omdb/nexus.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4072,7 +4072,7 @@ async fn cmd_nexus_support_bundles_list(
40724072
user_comment: String,
40734073
}
40744074
let rows = support_bundles.into_iter().map(|sb| SupportBundleInfo {
4075-
id: *sb.id,
4075+
id: sb.id,
40764076
time_created: sb.time_created,
40774077
reason_for_creation: sb.reason_for_creation,
40784078
reason_for_failure: sb

nexus/types/src/external_api/shared.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,6 +642,7 @@ pub enum SupportBundleState {
642642

643643
#[derive(Debug, Clone, JsonSchema, Serialize, Deserialize)]
644644
pub struct SupportBundleInfo {
645+
#[schemars(with = "Uuid")]
645646
pub id: SupportBundleUuid,
646647
pub time_created: DateTime<Utc>,
647648
pub reason_for_creation: String,

nexus/types/src/external_api/views.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,12 +1308,14 @@ pub struct AlertDelivery {
13081308
pub id: Uuid,
13091309

13101310
/// The UUID of the alert receiver that this event was delivered to.
1311+
#[schemars(with = "Uuid")]
13111312
pub receiver_id: AlertReceiverUuid,
13121313

13131314
/// The event class.
13141315
pub alert_class: String,
13151316

13161317
/// The UUID of the event.
1318+
#[schemars(with = "Uuid")]
13171319
pub alert_id: AlertUuid,
13181320

13191321
/// The state of this delivery.

openapi/nexus-internal.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8573,7 +8573,8 @@
85738573
"type": "object",
85748574
"properties": {
85758575
"id": {
8576-
"$ref": "#/components/schemas/TypedUuidForSupportBundleKind"
8576+
"type": "string",
8577+
"format": "uuid"
85778578
},
85788579
"reason_for_creation": {
85798580
"type": "string"
@@ -8843,10 +8844,6 @@
88438844
"type": "string",
88448845
"format": "uuid"
88458846
},
8846-
"TypedUuidForSupportBundleKind": {
8847-
"type": "string",
8848-
"format": "uuid"
8849-
},
88508847
"TypedUuidForUpstairsRepairKind": {
88518848
"type": "string",
88528849
"format": "uuid"

openapi/nexus.json

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13826,7 +13826,8 @@
1382613826
"type": "object",
1382713827
"properties": {
1382813828
"id": {
13829-
"$ref": "#/components/schemas/TypedUuidForInstanceKind"
13829+
"type": "string",
13830+
"format": "uuid"
1383013831
},
1383113832
"name": {
1383213833
"$ref": "#/components/schemas/Name"
@@ -13993,11 +13994,8 @@
1399313994
},
1399413995
"alert_id": {
1399513996
"description": "The UUID of the event.",
13996-
"allOf": [
13997-
{
13998-
"$ref": "#/components/schemas/TypedUuidForAlertKind"
13999-
}
14000-
]
13997+
"type": "string",
13998+
"format": "uuid"
1400113999
},
1400214000
"attempts": {
1400314001
"description": "Individual attempts to deliver this webhook event, and their outcomes.",
@@ -14014,11 +14012,8 @@
1401414012
},
1401514013
"receiver_id": {
1401614014
"description": "The UUID of the alert receiver that this event was delivered to.",
14017-
"allOf": [
14018-
{
14019-
"$ref": "#/components/schemas/TypedUuidForAlertReceiverKind"
14020-
}
14021-
]
14015+
"type": "string",
14016+
"format": "uuid"
1402214017
},
1402314018
"state": {
1402414019
"description": "The state of this delivery.",
@@ -14514,7 +14509,8 @@
1451414509
"type": "object",
1451514510
"properties": {
1451614511
"id": {
14517-
"$ref": "#/components/schemas/TypedUuidForInstanceKind"
14512+
"type": "string",
14513+
"format": "uuid"
1451814514
},
1451914515
"name": {
1452014516
"$ref": "#/components/schemas/Name"
@@ -24585,7 +24581,8 @@
2458524581
"type": "object",
2458624582
"properties": {
2458724583
"id": {
24588-
"$ref": "#/components/schemas/TypedUuidForSupportBundleKind"
24584+
"type": "string",
24585+
"format": "uuid"
2458924586
},
2459024587
"reason_for_creation": {
2459124588
"type": "string"
@@ -25995,22 +25992,6 @@
2599525992
}
2599625993
}
2599725994
},
25998-
"TypedUuidForAlertKind": {
25999-
"type": "string",
26000-
"format": "uuid"
26001-
},
26002-
"TypedUuidForAlertReceiverKind": {
26003-
"type": "string",
26004-
"format": "uuid"
26005-
},
26006-
"TypedUuidForInstanceKind": {
26007-
"type": "string",
26008-
"format": "uuid"
26009-
},
26010-
"TypedUuidForSupportBundleKind": {
26011-
"type": "string",
26012-
"format": "uuid"
26013-
},
2601425995
"UninitializedSled": {
2601525996
"description": "A sled that has not been added to an initialized rack yet",
2601625997
"type": "object",

0 commit comments

Comments
 (0)