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

Disable root volume validation #220

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/scripts/payload/CreateMicroVM.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"volumes": [
{
"id": "root",
"is_root": false,
"is_root": true,
"is_read_only": false,
"mount_point": "/",
"source": {
Expand Down
6 changes: 0 additions & 6 deletions pkg/validation/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,4 @@ func customMicroVMSpecStructLevelValidation(sl validator.StructLevel) {

return
}

if spec.Initrd != nil && found {
sl.ReportError(spec.Volumes, "volumes", "Volumes", "noRootVolumeIfInitrdSpecified", "")

return
}
}
17 changes: 17 additions & 0 deletions pkg/validation/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ func TestValidation_Invalid(t *testing.T) {
},
}

tooManyRoots := basicMicroVM
tooManyRoots.Spec.Volumes = models.Volumes{
{
IsRoot: true,
MountPoint: "/",
},
{
IsRoot: true,
MountPoint: "/",
},
}

tt := []struct {
name string
numErrors int
Expand Down Expand Up @@ -76,6 +88,11 @@ func TestValidation_Invalid(t *testing.T) {
numErrors: 1,
vmspec: invalidVolumes,
},
{
name: "should fail validation when more than one volume is marked as root",
numErrors: 1,
vmspec: tooManyRoots,
},
}

val := NewValidator()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func defaultTestMicroVM(name, namespace string) *types.MicroVMSpec {
Volumes: []*types.Volume{
{
Id: "root",
IsRoot: false,
IsRoot: true,
IsReadOnly: true,
MountPoint: "/",
Source: &types.VolumeSource{
Expand Down