Skip to content

Conversation

ricab
Copy link
Collaborator

@ricab ricab commented Oct 8, 2019

Check that the disk size requested on launch is not below the virtual size of the corresponding image. Fixes #701.

ricab added 2 commits October 8, 2019 12:04
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
Copy link

codecov bot commented Oct 8, 2019

Codecov Report

Merging #1120 into master will increase coverage by 0.34%.
The diff coverage is 82.6%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
...rc/platform/backends/qemu/qemu_virtual_machine.cpp 63.96% <0%> (ø) ⬆️
...c/platform/backends/shared/linux/backend_utils.cpp 66.66% <86.36%> (+17.21%) ⬆️
include/multipass/vm_image_info.h 0% <0%> (-100%) ⬇️
src/network/url_downloader.cpp 55.26% <0%> (-0.19%) ⬇️
src/daemon/daemon.cpp 31.33% <0%> (-0.06%) ⬇️
include/multipass/url_downloader.h 0% <0%> (ø) ⬆️
.../multipass/exceptions/aborted_download_exception.h 0% <0%> (ø)
src/daemon/default_vm_image_vault.cpp 78.86% <0%> (+5.03%) ⬆️
src/daemon/default_vm_image_vault.h 100% <0%> (+50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4cb4b93...b5c3fb8. Read the comment docs.

qemuimg_process->read_all_standard_error()));

const auto img_info = QString{qemuimg_process->read_all_standard_output()};
const auto capture_name = QStringLiteral("size");
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Bahh I totally forgot about this and just noticed this PR never got merged,

Copy link
Collaborator

@Saviq Saviq left a 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?

Comment on lines 111 to 112
throw std::runtime_error(fmt::format("Requested disk ({} bytes) below minimum for this image ({} bytes)",
requested_size.in_bytes(), min_size));
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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)

Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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.

@ricab
Copy link
Collaborator Author

ricab commented Oct 9, 2019

Could we unit-test this please?

Sure, I am working on it.

@ricab
Copy link
Collaborator Author

ricab commented Oct 11, 2019

Test are in. I still have to address the other review comments.

@ricab ricab force-pushed the check-min-img-size branch from 6701946 to 7a54647 Compare October 14, 2019 09:04
@ricab
Copy link
Collaborator Author

ricab commented Oct 14, 2019

CI-detected conflict addressed in canonical/multipass-private#187.

@Saviq
Copy link
Collaborator

Saviq commented Oct 16, 2019

@ricab if you rebase / merge this, the CI failure should go away.

@ricab
Copy link
Collaborator Author

ricab commented Oct 16, 2019

Bahh new test failure...

ricab added 2 commits October 16, 2019 12:21
Moves backend-util tests into new scheme + some formatting fixes.
Incidentally makes failing test pass (see #1003)!
@ricab
Copy link
Collaborator Author

ricab commented Oct 16, 2019

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.

@ricab ricab mentioned this pull request Oct 16, 2019
@multipass-ci-bot
Copy link
Collaborator

multipass-ci-bot commented Oct 23, 2019

macOS build available: multipass-0.10.0-dev.468+g422367d3.mac-Darwin.pkg
Snap build available: snap refresh multipass --channel edge/pr1120

@ricab
Copy link
Collaborator Author

ricab commented Oct 24, 2019

The conflict in CI is handled in canonical/multipass-private#190

Copy link
Collaborator

@Saviq Saviq left a 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+

bors bot added a commit that referenced this pull request Oct 29, 2019
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]>
@bors
Copy link
Contributor

bors bot commented Oct 29, 2019

Build failed

@Saviq Saviq merged commit b5c3fb8 into master Oct 29, 2019
@bors bors bot deleted the check-min-img-size branch October 29, 2019 14:17
Saviq pushed a commit that referenced this pull request Oct 29, 2019
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]>
@ricab
Copy link
Collaborator Author

ricab commented Oct 29, 2019

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:

  • test_image_resizing is a template: I remember looking briefly and not finding any obvious way to mix parameterized tests with templates
  • it would not gain me much: despite the many parameters, there weren't many combinations to test and the automated facilities to produce parameter combinations to test would not have been useful
  • test names would suffer: output would consist of a repeated name plus a load of parameters, instead of a specific, more descriptive, name for each test

@Saviq
Copy link
Collaborator

Saviq commented Oct 29, 2019

* it would not gain me much: despite the many parameters, there weren't many combinations to test and the automated facilities to produce parameter combinations to test would not have been useful

There would be less const autos though ;). But then, less readable because need to remember argument order, I suppose.

* test names would suffer: output would consist of a repeated name plus a load of parameters, instead of a specific, more descriptive, name for each test

FWIW this one can be solved by providing a naming function when instantiating the suite.

Thanks.

@ricab
Copy link
Collaborator Author

ricab commented Oct 29, 2019

There would be less const autos though ;). But then, less readable because need to remember argument order, I suppose.

Yeah they weren't necessary here either, I just wanted to make it easier to read.

FWIW this one can be solved by providing a naming function when instantiating the suite.

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 TEST(...) calls, but they would probably have to be replaced with comments for readability :)

@polarapfel
Copy link

I tried edge/pr1120 and I am still running into the issue with qemu-img being unable to resize the image and timing out.

@townsend2010
Copy link
Contributor

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?

@polarapfel
Copy link

Sure thing.

@polarapfel
Copy link

Hey @townsend2010, it's #1408.

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.

Multipass should provide better error message when unable to resize
5 participants