Use a status struct for RegionReplacementDetector#6564
Conversation
hawkw
left a comment
There was a problem hiding this comment.
Looks good to me overall! I suggested some very unimportant improvements, but none of them really matter --- if you don't care that much, feel free to ignore me! :)
| println!( | ||
| " number of region replacements started ok: {}", | ||
| success.region_replacement_started_ok | ||
| " number of region replacement requests created ok: \ |
There was a problem hiding this comment.
nit: maybe this line shouldn't begin with "number of" anymore, since it's now serving double-duty as showing the count and also as the header for the list of requests created?
| " number of region replacement requests created ok: \ | |
| " region replacement requests created ok: \ |
| println!( | ||
| " number of region replacement start errors: {}", | ||
| success.region_replacement_started_err | ||
| " number of region replacement start sagas started \ |
There was a problem hiding this comment.
similarly, maybe:
| " number of region replacement start sagas started \ | |
| " region replacement start sagas started \ |
| println!(" > {line}"); | ||
| } | ||
|
|
||
| println!(" number of errors: {}", status.errors.len()); |
There was a problem hiding this comment.
and again:
| println!(" number of errors: {}", status.errors.len()); | |
| println!(" errors: {}", status.errors.len()); |
| " number of region replacement drive sagas started ok: \ | ||
| {}", | ||
| status.drive_invoked_ok.len() | ||
| ); | ||
| for line in &status.drive_invoked_ok { | ||
| println!(" > {line}"); | ||
| } | ||
|
|
||
| println!( | ||
| " number of region replacement finish sagas started ok: {}", | ||
| " number of region replacement finish sagas started \ | ||
| ok: {}", |
There was a problem hiding this comment.
similarly, these lines now serve as the header for the list of entries invoked OK/errored, I wonder if we should remove the "number of"?
| number of region replacement requests created ok: 0 | ||
| number of region replacement start sagas started ok: 0 | ||
| number of errors: 0 |
There was a problem hiding this comment.
take it or leave it: if you want to be super-duper extra fancy and align the number columns programmatically, you could use the approach I took in #6541, using const_max_len to calculate the longest line to align to:
omicron/dev-tools/omdb/src/bin/omdb/nexus.rs
Lines 1193 to 1225 in a3917ea
totally up to you, though --- this is probably just me being a perfectionist.
There was a problem hiding this comment.
in this case, I'm going to leave it the way it is
| &log, | ||
| let s = format!( | ||
| "find_regions_on_expunged_physical_disks failed: {e}" | ||
| ); | ||
| err += 1; | ||
| error!(&log, "{s}"); | ||
| status.errors.push(s); |
There was a problem hiding this comment.
take it or leave it: it might be worth making the error be a structured field on the log entry, so that it can be easily searched with looker. maybe consider something like:
let message = "find_regions_on_expunged_physical_disks failed";
error!(&log, "{message}"; "error" => e);
status.errors.push(format!("{message}: {e}");but, it's not a huge deal.
There was a problem hiding this comment.
in this case, I'm also going to leave it the way it is - I noodled a bit with this suggestion but didn't like the repetition.
| let s = format!( | ||
| "error looking for existing region replacement \ | ||
| requests for {}: {e}", | ||
| region.id(), | ||
| ); | ||
| error!(&log, "{s}"); |
There was a problem hiding this comment.
similarly, it might be nice to make the IDs be structured fields in the log entry and only interpolate them into the error message when formatting the string for the status? not a big deal.
There was a problem hiding this comment.
(similar feedback applies to the other log messages here, of course)
There was a problem hiding this comment.
see above, going to skip this suggestion
Like the other replacement related background tasks, use a struct for the return value of the RegionReplacementDetector background task.
Like the other replacement related background tasks, use a struct for the return value of the RegionReplacementDetector background task.