-
Notifications
You must be signed in to change notification settings - Fork 40
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
[API] Bounds-check that disks are a minimum size, and use a minimum granularity size (#1029) #1150
Conversation
ryaeng
commented
Jun 3, 2022
- Requires the user to select a size of at least one gibibyte when creating a new disk.
- Add a test which attempts to create a disk that is 512 mebibytes in size.
…ranularity size (oxidecomputer#1029) - Requires the user to select a size of at least one gibibyte when creating a new disk. - Add a test which attempts to create a disk that is 512 mebibytes in size.
Hey Ryan - this change looks good to me; thanks for contributing (and thank you for adding a test)! I do have one minor request, both here and on #1157 . In some of our internal discussions, we mentioned that the choice here, although somewhat arbitrary, might change as we gather more information on use-cases. Could we define this value as a constant? Perhaps here: https://github.com/oxidecomputer/omicron/blob/main/nexus/src/external_api/params.rs , something like: const MAX_DISK_SIZE_BYTES: u32 = (1 << 30); // 1 GiB Then, in the test, we could just try creating a disk of |
nexus/src/app/disk.rs
Outdated
@@ -54,6 +54,17 @@ impl super::Nexus { | |||
), | |||
}); | |||
} | |||
|
|||
// Reject disks where the block size isn't at least |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To close out #1029 , could we do a granularity check too? EDIT: of 1 GiB, as well
(I think it's okay to be slightly redundant and have this be a separate check from the block device size)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with granularity checks. Can you explain this to me or point me in the right direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectively, it's a constraint on the divisibility of the requested size.
For example, although a 0.9 GiB disk can no longer be requested with this PR, a 1.1 GiB disk could be requested.
Our inclination is to be slightly more conservative - only allowing allocation requests of 1 GiB, 2 GiB, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it! Makes sense now. Thanks for the clarification.
Should this be MIN_DISK_SIZE_BYTES? |
Whoops, yes! |
- Add MIN_DISK_SIZE constant. - Modify tests to create disks with a size of MIN_DISK_SIZE / 2.
Sean, I've finished. What's the best way to go about amending my changes to this PR? |
Adding commits is the way to go - we have a policy of squashing to a single commit when PRs themselves are merged, but we generally have an append-only commit history within the context of a single PR. |
The disk size must be divisible by 1 GiB.
Done |
nexus/src/app/disk.rs
Outdated
return Err(Error::InvalidValue { | ||
label: String::from("size"), | ||
message: String::from( | ||
"total size must be at least 1 GiB", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The message is incorrect here, right? MIN_DISK_SIZE_BYTES
would need to included in the message instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Justin, I was curious about how to handle this one. I'll take care of that now. Thanks for your input.
instead of 1 GiB
nexus/src/app/disk.rs
Outdated
return Err(Error::InvalidValue { | ||
label: String::from("size"), | ||
message: String::from( | ||
"total size must be at least MIN_DISK_SIZE_BYTES", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error would be okay if this was just an internal error, but since this is user-facing, it might be a little harder to decipher.
I went ahead and made #1171 ; this should make it possible to just:
- Convert MIN_DISK_SIZE_BYTES to
ByteCount
- Display that directly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once this is committed I'll make sure to implement. Thanks, Sean.
Sean, I changed the error to utilize ByteCount::from. Works as intended. I'll do the same for memory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution! If the checks all pass, I'll merge
I'm also expanding the coverage of the tests that I've written. I'll push that shortly. |
Changed disk granularity test to be a multiple of the block_size.
Done |
Moving on to memory. |
Glad I did this. Found that my disk granularity test wasn't working properly. Needed to change the disk size to be a multiple of block_size in order to hit the right error. Fixed it. |
Crucible changes: Remove unused fields in IOop (#1149) New downstairs clone subcommand. (#1129) Simplify the do_work_task loop (#1150) Move `Guest` stuff into a module (#1125) Bump nix to 0.27.1 and use new safer Fd APIs (#1110) Move `FramedWrite` work to a separate task (#1145) Use fewer borrows in ExtentInner API (#1147) Update Rust crate reedline to 0.28.0 (#1141) Update Rust crate tokio to 1.36 (#1143) Update Rust crate slog-bunyan to 2.5.0 (#1139) Update Rust crate rayon to 1.8.1 (#1138) Update Rust crate itertools to 0.12.1 (#1137) Update Rust crate byte-unit to 5.1.4 (#1136) Update Rust crate base64 to 0.21.7 (#1135) Update Rust crate async-trait to 0.1.77 (#1134) Discard deferred msgs (#1131) Minor Downstairs cleanup (#1127) Update test_fail_live_repair to support pstop (#1128) Ignore client messages after stopping the IO task (#1126) Move client IO task into a struct (#1124) Bump Rust to 1.75 and fix new Clippy lints (#1123) Propolis changes: PHD: convert to async (#633) PHD: assume specialized Windows images (#636) propolis-standalone-config needn't be a crate standalone: Use tar for snapshot/restore phd: use latest "lab-2.0-opte" target, not a specific version (#637) PHD: add tests for migration of running processes (#623) PHD: fix `cargo xtask phd` tidy not doing anything (#630) PHD: add documentation for `cargo xtask phd` (#629) standalone: improve virtual device creation errors (#632) phd: add Windows Server 2019 guest adapter (#627) PHD: add `cargo xtask phd` to make using PHD nicer (#619)
Crucible changes: Remove unused fields in IOop (#1149) New downstairs clone subcommand. (#1129) Simplify the do_work_task loop (#1150) Move `Guest` stuff into a module (#1125) Bump nix to 0.27.1 and use new safer Fd APIs (#1110) Move `FramedWrite` work to a separate task (#1145) Use fewer borrows in ExtentInner API (#1147) Update Rust crate reedline to 0.28.0 (#1141) Update Rust crate tokio to 1.36 (#1143) Update Rust crate slog-bunyan to 2.5.0 (#1139) Update Rust crate rayon to 1.8.1 (#1138) Update Rust crate itertools to 0.12.1 (#1137) Update Rust crate byte-unit to 5.1.4 (#1136) Update Rust crate base64 to 0.21.7 (#1135) Update Rust crate async-trait to 0.1.77 (#1134) Discard deferred msgs (#1131) Minor Downstairs cleanup (#1127) Update test_fail_live_repair to support pstop (#1128) Ignore client messages after stopping the IO task (#1126) Move client IO task into a struct (#1124) Bump Rust to 1.75 and fix new Clippy lints (#1123) Propolis changes: PHD: convert to async (#633) PHD: assume specialized Windows images (#636) propolis-standalone-config needn't be a crate standalone: Use tar for snapshot/restore phd: use latest "lab-2.0-opte" target, not a specific version (#637) PHD: add tests for migration of running processes (#623) PHD: fix `cargo xtask phd` tidy not doing anything (#630) PHD: add documentation for `cargo xtask phd` (#629) standalone: improve virtual device creation errors (#632) phd: add Windows Server 2019 guest adapter (#627) PHD: add `cargo xtask phd` to make using PHD nicer (#619) Co-authored-by: Alan Hanson <alan@oxide.computer>