Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
ba42796
[ereport] index ereport ingestion by SP type/slot
hawkw Apr 1, 2025
cb673ec
we're calling them "restart IDs" now
hawkw Apr 1, 2025
8d66c09
whoopsie...
hawkw Apr 1, 2025
df3a493
unused variables
hawkw Apr 1, 2025
731966a
regenerate golden file
hawkw Apr 2, 2025
e324481
less structured ereport type
hawkw Apr 2, 2025
4cf9246
update mgs dep
hawkw Apr 3, 2025
49973ae
track unrelated mgs changes (factor me out pls)
hawkw Apr 3, 2025
20863c6
plumbing
hawkw Apr 3, 2025
f941a08
sp-sim plumbing
hawkw Apr 3, 2025
d1cd98b
wire up api (poorly)
hawkw Apr 3, 2025
a45ff03
demo hour
hawkw Apr 4, 2025
ff56b84
update for gatway fix
hawkw Apr 4, 2025
e69fc91
put fake interface in logs
hawkw Apr 4, 2025
f250ded
actually good errors
hawkw Apr 4, 2025
7d53fdb
pick up gateway messages tweaks
hawkw Apr 5, 2025
d1738a7
simulator improvements
hawkw Apr 5, 2025
7cc88ea
add ereports to sim sidecar
hawkw Apr 5, 2025
d481e21
hakari
hawkw Apr 5, 2025
619ccf4
give them both something to say
hawkw Apr 5, 2025
914dcd4
update MGS
hawkw Apr 7, 2025
539b0ce
honor limit
hawkw Apr 8, 2025
46c3612
update SP simulator
hawkw Apr 9, 2025
a7905e0
rm unused import
hawkw Apr 9, 2025
02b65b2
pass through ereport addrs in gateway-test-utils
hawkw Apr 10, 2025
64fd8f3
update to pick up request IDs from MGS
hawkw Apr 10, 2025
24b009b
simple ereport ingestion integration test
hawkw Apr 10, 2025
fea3438
so it turns out i'm stupid. fix that.
hawkw Apr 10, 2025
69a6c0a
add some simple ereport integration tests
hawkw Apr 11, 2025
4dd8878
pick up latest gateway-sp-comms
hawkw Apr 11, 2025
7ebf1d6
Merge branch 'main' into eliza/ereport-sp-api
hawkw Apr 11, 2025
7ea4ef3
fix sim mgs/sp SMF configs missing ereport addrs
hawkw Apr 12, 2025
9af73b6
update & track gateway-messages changes
hawkw Apr 15, 2025
0ff4977
unsandwich ENAs
hawkw Apr 17, 2025
b71609c
Merge branch 'main' into eliza/ereport-sp-api
hawkw Apr 28, 2025
f245a3f
update to track sp-sim changes from #8055
hawkw Apr 28, 2025
286bf61
Merge branch 'main' into eliza/ereport-sp-api
hawkw May 12, 2025
542ea63
who up managing they gateway service
hawkw May 12, 2025
645c4de
oof ouch oh no agh ouch ow
hawkw May 12, 2025
8eccf7b
PAIN
hawkw May 12, 2025
451a12e
fix ena type conversion
hawkw May 13, 2025
dd179e4
factor out udp bits
hawkw May 13, 2025
19b7cd0
cleanup imports
hawkw May 13, 2025
178dcef
more cleanup
hawkw May 13, 2025
2d09c6f
ENAs start at 1 now
hawkw May 13, 2025
9cb27a8
ENAs start at 1 now (across restarts)
hawkw May 13, 2025
aaa3c37
hakari update
hawkw May 13, 2025
2ecfb47
@cbiffle review feedback
hawkw May 13, 2025
fe5d3ca
nicer SP simulator logging
hawkw May 13, 2025
4bf8937
update api (oops)
hawkw May 13, 2025
04d967e
Update package-manifest.toml
hawkw May 13, 2025
368f84f
oh god i picked the wrong one of the three shas lol
hawkw May 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 17 additions & 34 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -409,8 +409,8 @@ gateway-client = { path = "clients/gateway-client" }
# is "fine", because SP/MGS communication maintains forwards and backwards
# compatibility, but will mean that faux-mgs might be missing new
# functionality.)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Less important on this commit than the upcoming one, but we should probably do what this comment says and update package-manifest.toml too.

gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "18215eeae855bd0a820ce00608a83d6ea9959596", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "18215eeae855bd0a820ce00608a83d6ea9959596" }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "e4f8749ae3eff7657e1d211440fcea272a090172", default-features = false, features = ["std"] }
gateway-sp-comms = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "e4f8749ae3eff7657e1d211440fcea272a090172" }
gateway-test-utils = { path = "gateway-test-utils" }
gateway-types = { path = "gateway-types" }
gethostname = "0.5.0"
Expand Down
88 changes: 40 additions & 48 deletions sp-sim/src/ereport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ impl EreportState {
let EreportRequest::V0(req) = request;
slog::info!(self.log, "ereport request: {req:?}");

let mut pos = gateway_messages::serialize(
buf,
&EreportResponseHeader::V0(ResponseHeaderV0 {
request_id: req.request_id,
restart_id: self.restart_id,
}),
)
.expect("header must serialize");

// If we "restarted", encode the current metadata map, and start at ENA
// 0.
let (meta_map, start_ena) = if req.restart_id != self.restart_id {
Expand Down Expand Up @@ -158,6 +149,30 @@ impl EreportState {

(&Default::default(), req.start_ena)
};

let mut respondant_ereports = self
.ereports
.iter()
.filter(|ereport| ereport.ena >= start_ena)
.take(req.limit as usize)
.peekable();
let start_ena = respondant_ereports
.peek()
.map(|ereport| ereport.ena)
.unwrap_or(Ena(start_ena.0 + 1));

// Serialize the header.
let mut pos = gateway_messages::serialize(
buf,
&EreportResponseHeader::V0(ResponseHeaderV0 {
request_id: req.request_id,
restart_id: self.restart_id,
start_ena,
}),
)
.expect("header must serialize");

// Serialize the metadata map.
pos += {
use serde::ser::SerializeMap;

Expand All @@ -179,59 +194,36 @@ impl EreportState {
cursor.position() as usize
};

// Is there enough remaining space for ereports? We need at least 10
// bytes (8 for the ENA, and at least two bytes to encode an empty CBOR
// list)
if buf[pos..].len() < 10 {
// Is there enough remaining space for ereports? We need at least two
// bytes to encode an empty CBOR list
if buf[pos..].len() <= 2 {
return &buf[..pos];
}

let mut respondant_ereports = self
.ereports
.iter()
.filter(|ereport| ereport.ena >= start_ena)
.take(req.limit as usize);
if let Some(EreportListEntry { ena, ereport, bytes }) =
respondant_ereports.next()
{
pos += gateway_messages::serialize(&mut buf[pos..], ena)
.expect("serialing ena shouldn't fail");
buf[pos] = 0x9f; // start list
pos += 1;
buf[pos] = 0x9f; // start list
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't need to block this PR, but: are there any cbor crates we could use here (we're already using ciborium elsewhere IIRC) to serialize this list? Or if that doesn't really work, do any of them happen to export this constant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, the reason that this part is a bit weird is because we want a particular behavior: we would like to put as many ereports as possible into the packet until the packet is full, and not write any bytes for any ereports that don't fit in the packet. This is why we build the list manually: just trying to use serde's serialize_seq with the whole iterator, or trying to serialize a Vec<Ereport> , would fail, but might have written some bytes from the last ereport that didn't fit before it failed, which is not the desired behavior. I think it might be possible to coax the lower-level serde API into letting us do that by serializing each entry individually and seeing if that call succeeds or fails, and tracking the last byte position after each successful serialization and chomping off anything past that. But, this felt like an easier way to do the same thing.

Unfortunately, none of the CBOR crates I looked at seemed to have constants for these bytes that were publicly exposed; per the ciborium docs it seems like they are planning to expose a lower-level library with things like that, but (AFAICT) it doesn't exist yet.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be worth changing this code and the MGS code to use ciborium instead of serde-cbor as it seems to provide most of the same APIs we need and seems more actively maintained, but I'd kind of rather do that in a separate branch that also updates MGS.

pos += 1;

// try to fill the rest of the packet with ereports
for EreportListEntry { ena, ereport, bytes } in respondant_ereports {
// packet full!
if buf[pos..].len() < (bytes.len() + 1) {
break;
}

buf[pos..pos + bytes.len()].copy_from_slice(&bytes[..]);
pos += bytes.len();
slog::debug!(
self.log,
"wrote initial ereport: {ereport:#?}";
"wrote ereport: {ereport:#?}";
"ena" => ?ena,
"packet_bytes" => pos,
"ereport_bytes" => bytes.len(),
);

// try to fill the rest of the packet
for EreportListEntry { ena, ereport, bytes } in respondant_ereports
{
// packet full!
if buf[pos..].len() < (bytes.len() + 1) {
break;
}

buf[pos..pos + bytes.len()].copy_from_slice(&bytes[..]);
pos += bytes.len();
slog::debug!(
self.log,
"wrote subsequent ereport: {ereport:#?}";
"ena" => ?ena,
"packet_bytes" => pos,
"ereport_bytes" => bytes.len(),
);
}

buf[pos] = 0xff; // break list;
pos += 1;
}

buf[pos] = 0xff; // break list;
pos += 1;

&buf[..pos]
}
}
Expand Down
4 changes: 2 additions & 2 deletions workspace-hack/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ futures-io = { version = "0.3.31" }
futures-sink = { version = "0.3.31" }
futures-task = { version = "0.3.31", default-features = false, features = ["std"] }
futures-util = { version = "0.3.31", features = ["channel", "io", "sink"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "a6b180dbb4262a94d73165a0d072b33376d174f8", features = ["std"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "e4f8749ae3eff7657e1d211440fcea272a090172", features = ["std"] }
generic-array = { version = "0.14.7", default-features = false, features = ["more_lengths", "zeroize"] }
getrandom-6f8ce4dd05d13bba = { package = "getrandom", version = "0.2.15", default-features = false, features = ["js", "rdrand", "std"] }
group = { version = "0.13.0", default-features = false, features = ["alloc"] }
Expand Down Expand Up @@ -178,7 +178,7 @@ futures-io = { version = "0.3.31" }
futures-sink = { version = "0.3.31" }
futures-task = { version = "0.3.31", default-features = false, features = ["std"] }
futures-util = { version = "0.3.31", features = ["channel", "io", "sink"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "a6b180dbb4262a94d73165a0d072b33376d174f8", features = ["std"] }
gateway-messages = { git = "https://github.com/oxidecomputer/management-gateway-service", rev = "e4f8749ae3eff7657e1d211440fcea272a090172", features = ["std"] }
generic-array = { version = "0.14.7", default-features = false, features = ["more_lengths", "zeroize"] }
getrandom-6f8ce4dd05d13bba = { package = "getrandom", version = "0.2.15", default-features = false, features = ["js", "rdrand", "std"] }
group = { version = "0.13.0", default-features = false, features = ["alloc"] }
Expand Down
Loading