-
Notifications
You must be signed in to change notification settings - Fork 624
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
add validation for nestedVirtualization, rosetta, and mountType #3127
base: master
Are you sure you want to change the base?
add validation for nestedVirtualization, rosetta, and mountType #3127
Conversation
14780e8
to
f458f0e
Compare
@AkihiroSuda kindly review. Also, I am not sure why unit tests are failing for windows, go version 1.22 and 1.23, even though everything looks fine. |
f458f0e
to
7772fb5
Compare
https://github.com/lima-vm/lima/actions/runs/12853756300/job/35837296730?pr=3127
|
I have tried to replicate it locally but it passes. Not sure what I'm missing |
5dc7b37
to
9c6b92d
Compare
@AkihiroSuda Found and fixed the issue. Thanks |
@olamilekan000 I don't know if all your pushes where necessary to deal with CI problems, but please be aware that each full CI run costs about $6 due to our use of large GitHub runners for macOS, and this PR had like 18 force-pushes1. That's ok if the problem is only reproducible in CI, but otherwise please try to resolve problems locally first. Footnotes
|
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've only reviewed the validate
changes, not the tests.
There may be more conditions that the validation could check for, but I'm out of time for now to think about it more.
Thanks for bringing this to my attention. The reason for that many pushes was due to me trying to figure why the test passes locally but fails with the CI. Apologies for the inconvenience |
9c6b92d
to
e5c21f4
Compare
4cba40b
to
4ec0da9
Compare
Signed-off-by: olalekan odukoya <[email protected]>
4ec0da9
to
a27ec96
Compare
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 are still invalid setting combinations that are not covered by tests.
It is a bit unfortunate that complete test coverage can only be achieved by running the test on each supported os and arch.
I think it would be better if the validation code had global variables for os and arch that can then be overridden in the tests to check for all scenarios with just a single local test run. But that should be a separate PR.
REVSSHFS: true, | ||
NINEP: true, | ||
VIRTIOFS: true, | ||
WSLMount: true, |
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.
You should have a test that on Windows the only valid mountType
is WSLMount
.
@@ -432,6 +463,9 @@ func validateNetwork(y *LimaYAML) error { | |||
return fmt.Errorf("field `%s.macAddress` must be a 48 bit (6 bytes) MAC address; actual length of %q is %d bytes", field, nw.MACAddress, len(hw)) | |||
} | |||
} | |||
if nw.VZNAT != nil && *nw.VZNAT && *y.VMType != VZ { | |||
return fmt.Errorf("field `%s.vzNAT` needs vmType set to %q; got %q", field, VZ, *y.VMType) |
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.
Similar errors should use similar wording. So always use requires
or always needs
(check what existing errors already use), and don't mix and match.
return fmt.Errorf("field `%s.vzNAT` needs vmType set to %q; got %q", field, VZ, *y.VMType) | |
return fmt.Errorf("field `%s.vzNAT` requires vmType %q; got %q", field, VZ, *y.VMType) |
@@ -372,6 +372,37 @@ func Validate(y *LimaYAML, warn bool) error { | |||
} | |||
} | |||
|
|||
if y.Rosetta.Enabled != nil && *y.Rosetta.Enabled && *y.VMType != VZ { |
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 check should also make sure the arch is aarch64
. Theoretically it should also check that the OS is darwin
, but you can set the vmType
to VZ
unless you are on macOS, so that should already be covered.
assert.NilError(t, err) | ||
|
||
err = Validate(y, false) | ||
assert.NilError(t, err) |
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 would have expected this to fail on Linux and Windows, which don't support the VZ vm type. If it doesn't fail validation on Linux, then that needs to be added.
assert.NilError(t, err) | ||
|
||
err = Validate(y, false) | ||
if runtime.GOOS == "darwin" && IsNativeArch(AARCH64) { |
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.
On Windows this should return a validation error that vm type QEMU is not supported.
y, err = Load([]byte(rosettaDisabled+"\n"+images), "lima.yaml") | ||
assert.NilError(t, err) | ||
|
||
err = Validate(y, false) |
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.
Again, expected to fail validation on Windows.
I'm stopping the review here; this continues to be an issue for the rest of the tests.
Instead of testing for the specific failure on e.g. Windows, I think you should probably skip the whole tests on platforms where they are expected to fail for different reasons than the one you are testing.
Fixes #3126