Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): add fstrim datadir observability #3322

Open
wants to merge 13 commits into
base: master
Choose a base branch
from

Conversation

andrewbattat
Copy link
Member

@andrewbattat andrewbattat commented Jan 3, 2025

NODE-1537

Node decommissioning stage 2 was rolled out in a hurry so that we could make the holiday-release cutoff: #2953

These changes add the missing observability logic.

Main commits:

Screenshot of metrics:
image

@andrewbattat andrewbattat self-assigned this Jan 3, 2025
@github-actions github-actions bot added the feat label Jan 3, 2025
@andrewbattat andrewbattat marked this pull request as ready for review January 3, 2025 19:45
@andrewbattat andrewbattat requested review from a team as code owners January 3, 2025 19:45
@fspreiss fspreiss requested a review from mbjorkqvist January 6, 2025 10:23
Copy link
Member

@mbjorkqvist mbjorkqvist left a comment

Choose a reason for hiding this comment

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

Thanks for also adding fstrim metrics for the data dir, @andrewbattat ! I made a (post-merge) comment on the previous PR that is somewhat unrelated to the changes you're making here, but it may have slipped through the cracks, so I thought I'd bring it up here also: #2953 (comment)
If you think it warrants some changes, those may fit better in a separate PR anyway.

rs/ic_os/fstrim_tool/src/metrics/mod.rs Outdated Show resolved Hide resolved
rs/ic_os/fstrim_tool/src/metrics/mod.rs Outdated Show resolved Hide resolved
rs/ic_os/fstrim_tool/tests/integration_tests.rs Outdated Show resolved Hide resolved
@@ -7,7 +7,7 @@ use std::time::Duration;
use tempfile::tempdir;

#[test]
fn should_compare_f64() {
fn test_f64_comparison() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these test_ prefixes add anything? I see them a lot but have the feeling it's just something people falsely do because it only adds noise.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm happy to drop them. I find the "test" prefix much more readable than the "should" prefix, but maybe that's just me.

I know what you mean about the extra noise, but I do like that it makes each function signature a verb phase so then the name is the thing it is doing. The work this function is doing isn't "f64_comparison" or "should_compare_f64". It's doing "test_f64_comparison"

Copy link
Member

Choose a reason for hiding this comment

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

+1, I think Rust conventions prefer you don't repeat yourself. I swear this shows up in the docs somewhere, but I couldn't seem to find the right link.

This shows up in enum naming:
IpAddr::V4 over IpAddr::IpV4

getters:

With a few exceptions, the get_ prefix is not used for getters in Rust code.

features:

Do not include words in the name of a Cargo feature that convey zero meaning, as in use-abc or with-abc. Name the feature abc directly.

and crates:

Crate names should not use -rs or -rust as a suffix or prefix. Every crate is Rust! It serves no purpose to remind users of this constantly.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good! Do you suggest just dropping all the test_ prefixes or reverting to the should_ prefix? I'd rather just drop the prefixes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should use should_ only when it helps with understanding what the test does.

When the test tests a specific expected behavior, we can describe that behavior with should_. In other cases, the test tests a scenario (and sometimes multiple behaviors are tested), in these cases we can describe the scenario and don't need should.

e.g:

  • without: f64_comparison, compare_f64
  • with: should_not_panic (not_panic would be a bad name)
  • in the middle: f64_comparison_should_not_panic

Copy link
Member Author

@andrewbattat andrewbattat Jan 9, 2025

Choose a reason for hiding this comment

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

Updated unit test naming:
2db1249

rs/ic_os/fstrim_tool/src/tests.rs Outdated Show resolved Hide resolved
let parsed_metrics_str = parsed_metrics.to_p8s_metrics_string();
let default_str = FsTrimMetrics::default().to_p8s_metrics_string();

assert_eq!(parsed_metrics_str, default_str);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not compare the actual metrics instead of their string representation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done! WDYT? 0e9874f

Copy link
Contributor

Choose a reason for hiding this comment

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

The parsing tests look good. However, it seems like we no longer test the output of to_p8s_metrics_string. It would make sense to have tests that parse that output (we have those) and other tests that recreate the output (where we check that the strings are formatted correctly).

Copy link
Member Author

Choose a reason for hiding this comment

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

Added! a5c9a21
WDYT?

rs/ic_os/fstrim_tool/src/tests.rs Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants