kubevirt / demo

Easy to use KubeVirt demo based on minikube.
Apache License 2.0
109 stars 59 forks source link

Deploy a VirtualMachine fails with "spec.domain.devices in body is required" #46

Closed simon3z closed 6 years ago

simon3z commented 6 years ago
$ kubectl apply -f https://raw.githubusercontent.com/kubevirt/demo/master/manifests/vm.yaml                                                                                                                                                    
offlinevirtualmachine.kubevirt.io "testvm" created             
The VirtualMachinePreset "small" is invalid: []: Invalid value: map[string]interface {}{"metadata":map[string]interface {}{"uid":"63604500-4792-11e8-80c4-8216f171324b", "selfLink":"", "clusterName":"", "annotations":map[string]interface {}{"kubectl.kubern
etes.io/last-applied-configuration":"{\"apiVersion\":\"kubevirt.io/v1alpha1\",\"kind\":\"VirtualMachinePreset\",\"metadata\":{\"annotations\":{},\"name\":\"small\",\"namespace\":\"myproject\"},\"spec\":{\"domain\":{\"resources\":{\"requests\":{\"memory\":
\"64M\"}}},\"selector\":{\"matchLabels\":{\"kubevirt.io/size\":\"small\"}}}}\n"}, "name":"small", "namespace":"myproject", "creationTimestamp":"2018-04-24T07:37:49Z"}, "spec":map[string]interface {}{"domain":map[string]interface {}{"resources":map[string]
interface {}{"requests":map[string]interface {}{"memory":"64M"}}}, "selector":map[string]interface {}{"matchLabels":map[string]interface {}{"kubevirt.io/size":"small"}}}, "apiVersion":"kubevirt.io/v1alpha1", "kind":"VirtualMachinePreset"}: validation fail
ure list:                                                                                                                                                                                                                                                      spec.domain.devices in body is required

Apparently adding an empty spec.domain.devices allowed me to move forward.

cc @fabiand

fabiand commented 6 years ago

Yes, that reminds me that I fixed it but didn't push the fix!

See https://github.com/kubevirt/demo/pull/44/commits/39a7319041d72a0d1bec0f623013836a21964fdb

In general it is probably a bug in Presets - @stu-gott ?

rmohr commented 6 years ago

I think it is our new openapi validation. We need to make sure that empty maps and no map are treated equally valid for such fields. Same for arrays. Could you file a bug against kubevirt?

rmohr commented 6 years ago

I think it is our new openapi validation. We need to make sure that empty maps and no map are treated equally valid for such fields. Same for arrays. Could you file a bug against kubevirt?

Oh actually it is the other way round. We need devices. We also need at least one disk in the devices section, so it should be even more strict ...

davidvossel commented 6 years ago

Oh actually it is the other way round. We need devices. We also need at least one disk in the devices section, so it should be even more strict ...

right, the empty devices field is just side stepping the CRD openapiv3 validation.

We need to make sure that empty maps and no map are treated equally valid for such fields.

no map vs empty map can mean different things. no map means the value is not set. an empty map means the map is initialized, but there are no values. These two states can be interpreted as meaning two separate things.

fabiand commented 6 years ago

Closed in current release.