Skip to content

Use a status struct for RegionReplacementDetector#6564

Merged
jmpesp merged 3 commits into
oxidecomputer:mainfrom
jmpesp:use_task_result_type
Sep 12, 2024
Merged

Use a status struct for RegionReplacementDetector#6564
jmpesp merged 3 commits into
oxidecomputer:mainfrom
jmpesp:use_task_result_type

Conversation

@jmpesp

@jmpesp jmpesp commented Sep 12, 2024

Copy link
Copy Markdown
Contributor

Like the other replacement related background tasks, use a struct for the return value of the RegionReplacementDetector background task.

@jmpesp jmpesp requested a review from hawkw September 12, 2024 18:39

@hawkw hawkw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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! :)

Comment thread dev-tools/omdb/src/bin/omdb/nexus.rs Outdated
println!(
" number of region replacements started ok: {}",
success.region_replacement_started_ok
" number of region replacement requests created ok: \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Suggested change
" number of region replacement requests created ok: \
" region replacement requests created ok: \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I like this, done in 831848c

Comment thread dev-tools/omdb/src/bin/omdb/nexus.rs Outdated
println!(
" number of region replacement start errors: {}",
success.region_replacement_started_err
" number of region replacement start sagas started \

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

similarly, maybe:

Suggested change
" number of region replacement start sagas started \
" region replacement start sagas started \

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

also 831848c

Comment thread dev-tools/omdb/src/bin/omdb/nexus.rs Outdated
println!(" > {line}");
}

println!(" number of errors: {}", status.errors.len());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

and again:

Suggested change
println!(" number of errors: {}", status.errors.len());
println!(" errors: {}", status.errors.len());

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

also 831848c

Comment thread dev-tools/omdb/src/bin/omdb/nexus.rs Outdated
Comment on lines +1314 to +1324
" 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: {}",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

also 831848c

Comment thread dev-tools/omdb/tests/successes.out Outdated
Comment on lines +592 to +594
number of region replacement requests created ok: 0
number of region replacement start sagas started ok: 0
number of errors: 0

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:

const VMMS_FOUND: &'static str = "total abandoned VMMs found:";
const VMMS_DELETED: &'static str = " VMM records deleted:";
const VMMS_ALREADY_DELETED: &'static str =
" VMMs already deleted by another Nexus:";
const SLED_RESERVATIONS_DELETED: &'static str =
"sled resource reservations deleted:";
// To align the number column, figure out the length of the
// longest line of text and add one (so that there's a space).
//
// Yes, I *could* just count the number of characters in each
// line myself, but why do something by hand when you could make
// the computer do it for you? And, this way, if we change the
// text, we won't need to figure it out again.
const WIDTH: usize = const_max_len(&[
VMMS_FOUND,
VMMS_DELETED,
VMMS_ALREADY_DELETED,
SLED_RESERVATIONS_DELETED,
]) + 1;
const NUM_WIDTH: usize = 3;
println!(" {VMMS_FOUND:<WIDTH$}{vmms_found:>NUM_WIDTH$}");
println!(
" {VMMS_DELETED:<WIDTH$}{vmms_deleted:>NUM_WIDTH$}"
);
println!(
" {VMMS_ALREADY_DELETED:<WIDTH$}{:>NUM_WIDTH$}",
vmms_already_deleted
);
println!(
" {SLED_RESERVATIONS_DELETED:<WIDTH$}{:>NUM_WIDTH$}",
sled_reservations_deleted,
);

totally up to you, though --- this is probably just me being a perfectionist.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

in this case, I'm going to leave it the way it is

Comment on lines -78 to +81
&log,
let s = format!(
"find_regions_on_expunged_physical_disks failed: {e}"
);
err += 1;
error!(&log, "{s}");
status.errors.push(s);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

cool, fine with me!

Comment on lines +101 to +106
let s = format!(
"error looking for existing region replacement \
requests for {}: {e}",
region.id(),
);
error!(&log, "{s}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(similar feedback applies to the other log messages here, of course)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

see above, going to skip this suggestion

@hawkw hawkw left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

👍

@jmpesp jmpesp enabled auto-merge (squash) September 12, 2024 21:24
@jmpesp jmpesp merged commit 887b3f0 into oxidecomputer:main Sep 12, 2024
@jmpesp jmpesp deleted the use_task_result_type branch September 13, 2024 01:00
Like the other replacement related background tasks, use a struct for
the return value of the RegionReplacementDetector background task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants