-
Notifications
You must be signed in to change notification settings - Fork 727
Check min img size #1120
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
Check min img size #1120
Conversation
Add newline to error messages of external processes. Matching existing format in other cases.
Check that the disk size requested on launch is not below the virtual size of the corresponding image. Fixes #701.
Codecov Report
@@ Coverage Diff @@
## master #1120 +/- ##
==========================================
+ Coverage 70.9% 71.24% +0.34%
==========================================
Files 200 201 +1
Lines 7327 7391 +64
==========================================
+ Hits 5195 5266 +71
+ Misses 2132 2125 -7
Continue to review full report at Codecov.
|
qemuimg_process->read_all_standard_error())); | ||
|
||
const auto img_info = QString{qemuimg_process->read_all_standard_output()}; | ||
const auto capture_name = QStringLiteral("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.
This seems a bit excessive… I don't think repeating "size" would be that big of a deal here, and having to substitute this in the pattern below… Your call.
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.
OK, I will do that.
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.
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.
Could we unit-test this please?
throw std::runtime_error(fmt::format("Requested disk ({} bytes) below minimum for this image ({} bytes)", | ||
requested_size.in_bytes(), min_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 think we should print this human-readable, we can probably assume GBs here, although now I see MemorySize
floors, would have to round up for this use case…
I'd be OK with this with a TODO to improve the message later.
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 considered that, but then users might get Requested disk (2.2G) below minimum for this image (2.2G)
, because of approximations. I used bytes to be precise and avoid that.
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.
So, this would happen when a user wanted to save space:
$ multipass launch --disk=1G
Requested disk (1G) below minimum for this image (2.2G)
$ multipass launch --disk=2.2G # user trying next-best thing
Requested disk (2.2G) below minimum for this image (2.2G)
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.
Well of course, which is why I mentioned we'd need to ceil()
the minimum, in which case the minimum would be 2.3G
.
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 see, I did not get what you meant before. OK then, fine by me. It would be imprecise, but I agree it looks friendlier.
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.
MemorySize
does not support decimals ATM, so I will add the TODO for now.
Sure, I am working on it. |
Change process counting strategy to accommodate test repetitions, while hopefully improving clarity.
Test are in. I still have to address the other review comments. |
Employ it in test checking no resizing when below minimum.
6701946
to
7a54647
Compare
CI-detected conflict addressed in canonical/multipass-private#187. |
@ricab if you rebase / merge this, the CI failure should go away. |
Bahh new test failure... |
Moves backend-util tests into new scheme + some formatting fixes.
Incidentally makes failing test pass (see #1003)!
The failure is just another manifestation of #1003. I tried a shot at changing the order of our sources in cmake and it made it go away! At least in my machine, let's see what CI says. I kept that change as a separate commit on purpose. In summary, the failure in c5eacaf (merge commit) goes away in f502847. Something that will byte us back again for sure, but not really related to this PR. |
macOS build available: multipass-0.10.0-dev.468+g422367d3.mac-Darwin.pkg |
The conflict in CI is handled in canonical/multipass-private#190 |
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, love the coverage :)
Can you just comment on why you didn't go for parameterized tests here? It seems as if test_image_resizing
could really itself be a parameterized test?
bors r+
1120: Check min img size r=Saviq a=ricab Check that the disk size requested on launch is not below the virtual size of the corresponding image. Fixes #701. Co-authored-by: Ricardo Abreu <[email protected]>
Build failed |
1120: Check min img size r=Saviq a=ricab Check that the disk size requested on launch is not below the virtual size of the corresponding image. Fixes #701. Co-authored-by: Ricardo Abreu <[email protected]>
Thanks! Yeah, the tests took most of the time. I considered parameterized tests but ended up deciding against. I forget the exact reasoning at the time, but I think the main reasons were:
|
There would be less
FWIW this one can be solved by providing a naming function when instantiating the suite. Thanks. |
Yeah they weren't necessary here either, I just wanted to make it easier to read.
Interesting! I overlooked that. TBH, an important reason was that I had already spent a lot of time on these tests and wanted to move on. But I also did not see much advantage. I would remove a bunch of |
I tried edge/pr1120 and I am still running into the issue with qemu-img being unable to resize the image and timing out. |
Hi @polarapfel, It sounds to me the issue you are seeing is unrelated to this PR. Could you please submit a new issue and put in your reproduction steps? |
Sure thing. |
Hey @townsend2010, it's #1408. |
Check that the disk size requested on launch is not below the virtual size of the corresponding image. Fixes #701.