Skip to content

Commit 9b85b61

Browse files
authored
[wicketd] Add periodic check for sled agent bootstrap addrs (#3327)
RSS wants to know the bootstrap addresses of the sleds to include; this PR teaches wicketd how to find them. It also updates the wicket TOML config introduced in #3326 to include the sled's bootstrap address (if known) in a comment in the sled list; I'm unsure if this is something we'll want to keep once customers are running RSS, but it seems handy for debugging for now. Builds on #3326.
1 parent 3ade708 commit 9b85b61

File tree

11 files changed

+379
-51
lines changed

11 files changed

+379
-51
lines changed

Cargo.lock

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

openapi/wicketd.json

Lines changed: 64 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,30 @@
107107
}
108108
}
109109
},
110+
"/bootstrap-sleds": {
111+
"get": {
112+
"summary": "Get wicketd's current view of all sleds visible on the bootstrap network.",
113+
"operationId": "get_bootstrap_sleds",
114+
"responses": {
115+
"200": {
116+
"description": "successful operation",
117+
"content": {
118+
"application/json": {
119+
"schema": {
120+
"$ref": "#/components/schemas/BootstrapSledIps"
121+
}
122+
}
123+
}
124+
},
125+
"4XX": {
126+
"$ref": "#/components/responses/Error"
127+
},
128+
"5XX": {
129+
"$ref": "#/components/responses/Error"
130+
}
131+
}
132+
}
133+
},
110134
"/clear-update-state/{type}/{slot}": {
111135
"post": {
112136
"summary": "Resets update state for a sled.",
@@ -664,26 +688,52 @@
664688
"BootstrapSledDescription": {
665689
"type": "object",
666690
"properties": {
667-
"id": {
668-
"$ref": "#/components/schemas/SpIdentifier"
691+
"baseboard": {
692+
"$ref": "#/components/schemas/Baseboard"
669693
},
670-
"model": {
671-
"type": "string"
694+
"bootstrap_ip": {
695+
"nullable": true,
696+
"description": "The sled's bootstrap address, if the host is on and we've discovered it on the bootstrap network.",
697+
"type": "string",
698+
"format": "ipv6"
672699
},
673-
"revision": {
674-
"type": "integer",
675-
"format": "uint32",
676-
"minimum": 0
700+
"id": {
701+
"$ref": "#/components/schemas/SpIdentifier"
702+
}
703+
},
704+
"required": [
705+
"baseboard",
706+
"id"
707+
]
708+
},
709+
"BootstrapSledIp": {
710+
"type": "object",
711+
"properties": {
712+
"baseboard": {
713+
"$ref": "#/components/schemas/Baseboard"
677714
},
678-
"serial_number": {
679-
"type": "string"
715+
"ip": {
716+
"type": "string",
717+
"format": "ipv6"
680718
}
681719
},
682720
"required": [
683-
"id",
684-
"model",
685-
"revision",
686-
"serial_number"
721+
"baseboard",
722+
"ip"
723+
]
724+
},
725+
"BootstrapSledIps": {
726+
"type": "object",
727+
"properties": {
728+
"sleds": {
729+
"type": "array",
730+
"items": {
731+
"$ref": "#/components/schemas/BootstrapSledIp"
732+
}
733+
}
734+
},
735+
"required": [
736+
"sleds"
687737
]
688738
},
689739
"CertificateUploadResponse": {

sled-hardware/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,16 @@ pub enum SledMode {
7474

7575
/// Describes properties that should uniquely identify a Gimlet.
7676
#[derive(
77-
Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, JsonSchema,
77+
Clone,
78+
Debug,
79+
PartialOrd,
80+
Ord,
81+
PartialEq,
82+
Eq,
83+
Hash,
84+
Serialize,
85+
Deserialize,
86+
JsonSchema,
7887
)]
7988
#[serde(tag = "type", rename_all = "snake_case")]
8089
pub enum Baseboard {

wicket/src/rack_setup/config_toml.rs

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,29 @@ fn format_multiline_array(array: &mut Array) {
106106
}
107107

108108
fn build_sleds_array(sleds: &[BootstrapSledDescription]) -> Array {
109+
// Helper function to build the comment attached to a given sled.
110+
fn sled_comment(sled: &BootstrapSledDescription, end: &str) -> String {
111+
use wicketd_client::types::Baseboard;
112+
let ip = sled
113+
.bootstrap_ip
114+
.map(|ip| Cow::from(format!("{ip}")))
115+
.unwrap_or_else(|| Cow::from("IP address UNKNOWN"));
116+
match &sled.baseboard {
117+
Baseboard::Gimlet { identifier, model, revision } => {
118+
format!(
119+
" # {identifier} (model {model} revision {revision}, {ip})\
120+
{end}"
121+
)
122+
}
123+
Baseboard::Unknown => {
124+
format!(" # UNKNOWN SLED ({ip}){end}")
125+
}
126+
Baseboard::Pc { identifier, model } => {
127+
format!(" # NON-GIMLET {identifier} (model {model}, {ip}){end}")
128+
}
129+
}
130+
}
131+
109132
let mut array = Array::new();
110133
let mut prev: Option<&BootstrapSledDescription> = None;
111134

@@ -121,13 +144,7 @@ fn build_sleds_array(sleds: &[BootstrapSledDescription]) -> Array {
121144
// We have to attach the comment for each sled on the _next_ item in the
122145
// array, so here we set our prefix to be the previous item's details.
123146
if let Some(prev) = prev {
124-
decor.set_prefix(format!(
125-
" # {serial} (model {model}, revision {rev}){sep}",
126-
serial = prev.serial_number,
127-
model = prev.model,
128-
rev = prev.revision,
129-
sep = ARRAY_SEP,
130-
));
147+
decor.set_prefix(sled_comment(prev, ARRAY_SEP));
131148
} else {
132149
decor.set_prefix(ARRAY_SEP);
133150
}
@@ -139,12 +156,7 @@ fn build_sleds_array(sleds: &[BootstrapSledDescription]) -> Array {
139156
// Because we attach comments to previous items, we also need to add a
140157
// comment to the last element.
141158
if let Some(prev) = prev {
142-
array.set_trailing(format!(
143-
" # {serial} (model {model}, revision {rev})\n",
144-
serial = prev.serial_number,
145-
model = prev.model,
146-
rev = prev.revision,
147-
));
159+
array.set_trailing(sled_comment(prev, "\n"));
148160
array.set_trailing_comma(true);
149161
}
150162

@@ -189,7 +201,9 @@ fn populate_network_table(
189201
mod tests {
190202
use super::*;
191203
use omicron_common::api::internal::shared::RackNetworkConfig as InternalRackNetworkConfig;
204+
use std::net::Ipv6Addr;
192205
use wicket_common::rack_setup::PutRssUserConfigInsensitive;
206+
use wicketd_client::types::Baseboard;
193207
use wicketd_client::types::PortFec;
194208
use wicketd_client::types::PortSpeed;
195209
use wicketd_client::types::SpIdentifier;
@@ -258,15 +272,21 @@ mod tests {
258272
bootstrap_sleds: vec![
259273
BootstrapSledDescription {
260274
id: SpIdentifier { slot: 1, type_: SpType::Sled },
261-
model: "model1".into(),
262-
revision: 3,
263-
serial_number: "serial 1 2 3".into(),
275+
baseboard: Baseboard::Gimlet {
276+
model: "model1".into(),
277+
revision: 3,
278+
identifier: "serial 1 2 3".into(),
279+
},
280+
bootstrap_ip: None,
264281
},
265282
BootstrapSledDescription {
266283
id: SpIdentifier { slot: 5, type_: SpType::Sled },
267-
model: "model2".into(),
268-
revision: 5,
269-
serial_number: "serial 4 5 6".into(),
284+
baseboard: Baseboard::Gimlet {
285+
model: "model2".into(),
286+
revision: 5,
287+
identifier: "serial 4 5 6".into(),
288+
},
289+
bootstrap_ip: Some(Ipv6Addr::LOCALHOST),
270290
},
271291
],
272292
dns_servers: vec!["1.1.1.1".into(), "2.2.2.2".into()],

wicketd-client/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ progenitor::generate_api!(
3737
Ipv4Range = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
3838
Ipv6Range = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
3939
IpRange = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
40+
Baseboard = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
4041
BootstrapSledDescription = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
4142
RackNetworkConfig = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },
4243
CurrentRssUserConfigInsensitive = { derives = [ PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize ] },

wicketd/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ toml.workspace = true
3636
uuid.workspace = true
3737

3838
bootstrap-agent-client.workspace = true
39+
ddm-admin-client.workspace = true
3940
gateway-client.workspace = true
4041
installinator-artifactd.workspace = true
4142
installinator-common.workspace = true

0 commit comments

Comments
 (0)