Description of problem: As subject Version-Release number of selected component (if applicable): ovirt: ovirt-engine-4.0.6.3-0.1.el7ev.noarch rhev host: libvirt-2.0.0-10.virtcov.el7_3.3.x86_64 qemu-kvm-rhev-2.6.0-28.el7_3.2.x86_64 vdsm-4.19.1-1.el7ev.x86_64 ovirt sdk: ovirt-engine-sdk-python-4.0.4 How reproducible: 80% Steps to Reproduce: 1. Setup a RHEV environment with 2 rhev hosts, one running VM. 2. Run following scripts: ``` #!/bin/python import ovirtsdk4 as sdk import logging import time connection = sdk.Connection(url="xxxx", username='admin@internal', password='xxx', insecure=True, log=logging.getLogger()) vms_service = connection.system_service().vms_service() def get_vm(vms_service): return vms_service.list(search='MY_VM')[0] vm = get_vm(vms_service) vm_service = vms_service.vm_service(vm.id) while True: print get_vm(vms_service).status if get_vm(vms_service).status.value is 'up': print 'vm will be migrated' vm_service.migrate() time.sleep(1) print get_vm(vms_service).status.value elif get_vm(vms_service).status.value is 'down': print 'Bugs!\n' break time.sleep(2) ``` Actual results: The script result: up vm will be migrated migrating migrating migrating migrating migrating migrating migrating migrating migrating migrating migrating up vm will be migrated Traceback (most recent call last): File "/tmp/ovirt_mig.py", line 19, in <module> vm_service.migrate() File "/usr/lib64/python2.7/site-packages/ovirtsdk4/services.py", line 24203, in migrate self._check_action(response) File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 129, in _check_action Service._raise_error(response, result.fault) File "/usr/lib64/python2.7/site-packages/ovirtsdk4/service.py", line 71, in _raise_error raise Error(msg) ovirtsdk4.Error: Fault reason is "Operation Failed". Fault detail is "[Cannot migrate VM. VM hhan_N_A is being migrated.]". HTTP response code is 409. VM's status is up but cannot be migrated. Expected results: VM can be migrated when its status is up. Additional info:
Logs? In general such check is too simplistic. But let's see the exact reason in logs
Severity?
Also, please reproduce on 4.0.6 first.
Created attachment 1237488 [details] The logs of ovirt-engine and vdsmd The logs of ovirt-engine and vdsmd during running the migration script. ovirt-engine version: ovirt-engine-4.0.6.3-0.1.el7ev.noarch
Does the migration pass if you than wait for some time? Or is the VM locked in this state forever?
The migration will pass if wait for several seconds. For example, if I add time.sleep(2) before migrate function, migrations will pass. Scripts like following: ``` #!/bin/python import ovirtsdk4 as sdk import logging import time connection = sdk.Connection(url='https://xxx/ovirt-engine/api', username='admin@internal', password='xxx', insecure=True, log=logging.getLogger()) vms_service = connection.system_service().vms_service() def get_vm(vms_service): return vms_service.list(search='h-NFS')[0] vm = get_vm(vms_service) vm_service = vms_service.vm_service(vm.id) while True: print get_vm(vms_service).status if get_vm(vms_service).status.value is 'up': print 'vm will be migrated' time.sleep(2) vm_service.migrate() print get_vm(vms_service).status.value elif get_vm(vms_service).status.value is 'down': print 'Bugs!\n' print time.time() break time.sleep(2) ```
OK, this is actually not a bug. The "UP" status is what the VM is doing from libvirt perspective. But from engine perspective it is a bit different, there is locking involved. The VM is actually locked due to migration and when you try to migrate it, it will complain that you can not because it is migrating. There is a very short gap between this two things, but using a script you can hit it.