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

If user forgets to add "M" to the -M flag, kraft silently uses default memory amount #1382

Closed
felipehuici opened this issue Mar 6, 2024 · 1 comment · Fixed by #1425
Closed
Labels
kind/bug Something isn't working priority/medium Issue which is important, but KraftKit is usable without it also.

Comments

@felipehuici
Copy link
Member

Describe the bug

If user forgets to add "M" to the -M flag, kraft silently uses defaults memory amount, which can cause the app to fail without giving the user much indication as to why.

Steps to reproduce

Run something like:

kraft run --rm -p 1313:1313 --plat qemu --arch x86_64 -M 512 # NOTE: no "M" after 512

on any app that requires more than the default amount of memory (which I think is 64M)

Expected behavior

kraft should probably give an error, saying that the unit is missing, and stopping, rather than silently continuing, applying (silently again) the memory default, and then potentially failing if the app needs memory, without the user understanding why.

Which architectures were you using or does this bug affect?

x86_64

Which operating system were you using or does this bug affect?

macOS

Relevant log output

% kraft run --rm -p 1313:1313 --plat qemu --arch x86_64 -M 512
 W  using hardware emulation
 i  using arch=x86_64 plat=qemu
[+] pulling unikraft.org/hugo:latest (qemu/x86_64) •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 100% [1m 46s]
[+] building rootfs... done!                                                                                                                                    x86_64 [3.1s]
 E  machine fatally exited
@felipehuici felipehuici added kind/bug Something isn't working priority/medium Issue which is important, but KraftKit is usable without it also. labels Mar 6, 2024
@craciunoiuc
Copy link
Member

This happens because no unit defaults to Bytes, and if the size is smaller than 1MB it goes down to 0 because of the division and conversion to int

I will limit the input to at least one MiB

craciunoiuc added a commit to craciunoiuc/kraftkit that referenced this issue Mar 18, 2024
Lower values would get divided by Mi and turned to 0, which defaulted to 64Mi.

GitHub-Fixes: unikraft#1382
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
craciunoiuc added a commit to craciunoiuc/kraftkit that referenced this issue Mar 18, 2024
Lower values would get divided by Mi and turned to 0, which defaulted
to 64Mi.

GitHub-Fixes: unikraft#1382
Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
craciunoiuc added a commit to craciunoiuc/kraftkit that referenced this issue Mar 19, 2024
Lower values would get divided by Mi and turned to 0, which defaulted
to 64Mi.

GitHub-Fixes: unikraft#1382

Signed-off-by: Cezar Craciunoiu <cezar.craciunoiu@unikraft.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working priority/medium Issue which is important, but KraftKit is usable without it also.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants