Bug 1409033 - Unable to migrate VM when VM's status is up when continuous migrating
Summary: Unable to migrate VM when VM's status is up when continuous migrating
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: ovirt-engine
Classification: oVirt
Component: RestAPI
Version: 4.0.6.3
Hardware: Unspecified
OS: Linux
unspecified
low
Target Milestone: ---
: ---
Assignee: Juan Hernández
QA Contact: Pavel Stehlik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-12-29 02:36 UTC by Han Han
Modified: 2017-01-25 08:56 UTC (History)
4 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2017-01-25 08:56:03 UTC
oVirt Team: Virt
Embargoed:


Attachments (Terms of Use)
The logs of ovirt-engine and vdsmd (16.14 KB, application/x-gzip)
2017-01-05 01:55 UTC, Han Han
no flags Details

Description Han Han 2016-12-29 02:36:31 UTC
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:

Comment 1 Michal Skrivanek 2016-12-29 06:17:38 UTC
Logs?
In general such check is too simplistic. But let's see the exact reason in logs

Comment 2 Yaniv Kaul 2016-12-29 09:56:33 UTC
Severity?

Comment 3 Yaniv Kaul 2016-12-29 09:57:55 UTC
Also, please reproduce on 4.0.6 first.

Comment 4 Han Han 2017-01-05 01:55:44 UTC
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

Comment 5 Tomas Jelinek 2017-01-11 09:52:14 UTC
Does the migration pass if you than wait for some time?
Or is the VM locked in this state forever?

Comment 6 Han Han 2017-01-11 10:06:13 UTC
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)

```

Comment 7 Tomas Jelinek 2017-01-25 08:56:03 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.