Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: If the name in the top-level metadata section of a VirtualMachine definition does not match the name defined in the metadata of the 'template' section of the definition, both a VM and VMI will be created but with different names. This prevents the controller from reconciling the VM to the running VMI. The VM will be stuck in a pending state, even though the VMI is fine. Version-Release number of selected component (if applicable): OpenShift virtualization 2.3 How reproducible: Always Steps to Reproduce: 1. Create a template where the metadata's do not match: apiVersion: kubevirt.io/v1alpha3 kind: VirtualMachine metadata: name: myfriendlyvmname spec: <...> running: true template: metadata: name: someothevmname spec: domain: resources: <...> 2. oc create -f <vm file> Actual results: oc get vm reports: Warning FailedCreate 41s (x17 over 61s) virtualmachine-controller Error creating virtual machine instance: The POST operation against VirtualMachineInstance.kubevirt.io could not be completed at this time, please try again. The virt-controller logs show its confusion: {"component":"virt-controller","kind":"","level":"info","msg":"Failed to create VirtualMachineInstance: /","name":"myfriendlyvmname","namespace":"default","pos":"vm.go:641","service":"http","timestamp":"2020-05-08T21:36:37.043785Z","uid":"bfde9daa-2bdf-44b6-bca3-9ad83fd9ab42"} {"component":"virt-controller","kind":"","level":"error","msg":"Creating the VirtualMachine failed.","name":"myfriendlyvmname","namespace":"default","pos":"vm.go:265","service":"http","timestamp":"2020-05-08T21:36:37.043848Z","uid":"bfde9daa-2bdf-44b6-bca3-9ad83fd9ab42"} {"component":"virt-controller","kind":"","level":"info","msg":"Reason to fail: FailedCreate","name":"myfriendlyvmname","namespace":"default","pos":"vm.go:1225","service":"http","timestamp":"2020-05-08T21:36:37.043887Z","uid":"bfde9daa-2bdf-44b6-bca3-9ad83fd9ab42"} {"component":"virt-controller","level":"info","msg":"reenqueuing VirtualMachineInstance default/someothevmname","pos":"vmi.go:201","reason":"Operation cannot be fulfilled on virtualmachineinstances.kubevirt.io \"someothevmname\": the object has been modified; please apply your changes to the latest version and try again","service":"http","timestamp":"2020-05-08T21:36:37.058788Z"} {"component":"virt-controller","level":"info","msg":"re-enqueuing VirtualMachine default/myfriendlyvmname","pos":"vm.go:143","reason":"The POST operation against VirtualMachineInstance.kubevirt.io could not be completed at this time, please try again.","service":"http","timestamp":"2020-05-08T21:36:37.061318Z"} {"component":"virt-controller","level":"info","msg":"reenqueuing VirtualMachineInstance default/someothevmname","pos":"vmi.go:201","reason":"Operation cannot be fulfilled on virtualmachineinstances.kubevirt.io \"someothevmname\": the object has been modified; please apply your changes to the latest version and try again","service":"http","timestamp":"2020-05-08T21:36:37.067814Z"} (note the different names) The result is VM myfriendlyvmname is in a pending state, while VMI someothevmname is running fine. Expected results: VM resultant VMI are created and associated with each other Additional info: Not sure if this is a template validation issue, or a doc issue. Omitting a name in the metadata section of the VM template also works fine, since it must inherit from the top-level spec. It seems optional, put possible to override in the VM template and cause a bit of a split-brain. Perhaps a name shouldn't be allowed in the VM template's metadata?
I am able to reproduce this on both the CNV 2.3.0 code as well as the latest code on the master branch. Everything does appear to be operating normally, however there is a Failure condition on the VM: status: conditions: - lastProbeTime: null lastTransitionTime: "2020-05-13T19:25:38Z" message: The POST operation against VirtualMachineInstance.kubevirt.io could not be completed at this time, please try again. reason: FailedCreate status: "True" type: Failure Vatsal, would you mind taking a look at this? You recently touched the VM/VMI naming logic so might have some insights.
Is this a special case we support (different names for parent VM and child VMI)? If not, a validating webhook would solve the issue, or completely omitting the 'template.name` field and letting a mutating webhook insert the parent VM to the 'template` section.
Roman has this PR for this, https://github.com/kubevirt/kubevirt/pull/3436
Backport created: https://github.com/kubevirt/kubevirt/pull/3643
PRs are merged. The new behaviour is now consistend with Pod templates on other controllers like Deployments, ReplicaSets and with VMI templates on the VirtualMachineInstanceReplicaSet. In all cases generateName and name are now ignored on the template.
Fixed-in version was applied in error.
I can reproduce this. verify with build virt-operator-container-v2.4.0-52 $ virtctl version Server Version: version.Info{GitVersion:"v0.30.3", GitCommit:"bf49699ddf2639f5d40d8cff5db49be632a165bd", GitTreeState:"clean", BuildDate:"2020-07-01T01:28:15Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64" step: create a vm like bug description, and start the vm ... metadata: labels: kubevirt.io/vm: vm-cirros-nfs name: vm-cirros-nfs spec: running: false template: metadata: name: someothervmname labels: kubevirt.io/vm: vm-cirros-nfs ... check Virt-controller logs, there is no fail msg. check vm status $ oc get vmi NAME AGE PHASE IP NODENAME vm-cirros-nfs 8m14s Running 10.131.0.35 zpeng-cnv24-jvfn5-worker-l7fmw the name in template is ignored. move to verified.
I have added a placeholder in the 2.4 release notes for this defect. Requested for doc text, in waiting mode. Thank.
(In reply to Lavanya Mandavilli from comment #10) > I have added a placeholder in the 2.4 release notes for this defect. > Requested for doc text, in waiting mode. Thank. You mean a release note that it is fixed? How about: ``` If the name for a VMI is specified in the VMI template of the VM, it is correctly ignored now. The VM and VMI name will always match. ```
@rmohr, @fabiand - This PR is ready for review:https://github.com/openshift/openshift-docs/pull/23994 Please add your edits/comments.
Feedback from @rmohr was incorporated.
Updating this defect. After conferring with @aburdenhand, it was noted that this defect was fixed - therefore, this does not fall into the classification of known issues. Removing this info from the Known Issues section of the release notes.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://access.redhat.com/errata/RHSA-2020:3194