Bug 906360

Summary: [rest-api] created direct lun has missing values in db
Product: Red Hat Enterprise Virtualization Manager Reporter: Jakub Libosvar <jlibosva>
Component: ovirt-engine-restapiAssignee: Liron Aravot <laravot>
Status: CLOSED CURRENTRELEASE QA Contact: Katarzyna Jachim <kjachim>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 3.2.0CC: abaron, acathrow, amureini, dyasny, hateya, iheim, mpastern, ncredi, oramraz, Rhev-m-bugs, scohen, ykaul
Target Milestone: ---Keywords: Regression, TestBlocker
Target Release: 3.2.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: storage
Fixed In Version: sf10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
engine.log none

Description Jakub Libosvar 2013-01-31 13:56:14 UTC
Created attachment 690914 [details]
engine.log

Description of problem:
Lun was created by sending POST to api/disks with body
<disk>
    <alias>direct_lun</alias>
    <interface>virtio</interface>
    <format>cow</format>
    <lun_storage>
        <type>iscsi</type>
        <logical_unit id="360014055ff2afd2a4474cc2b44d65b0e">
            <address>10.35.64.81</address>
            <port>3260</port>
            <target>iqn.2003-01.org.linux-iscsi.lion.x8664:sn.20121002152127.jenkins-vm-01</target>
        </logical_unit>
    </lun_storage>
</disk>

Obtained response:
<disk href="/api/disks/85887360-4458-4536-9269-a2822b722cd9" id="85887360-4458-4536-9269-a2822b722cd9">
    <name>direct_lun</name>
    <link href="/api/disks/85887360-4458-4536-9269-a2822b722cd9/permissions" rel="permissions"/>
    <link href="/api/disks/85887360-4458-4536-9269-a2822b722cd9/statistics" rel="statistics"/>
    <alias>direct_lun</alias>
    <interface>virtio</interface>
    <bootable>false</bootable>
    <shareable>false</shareable>
    <wipe_after_delete>false</wipe_after_delete>
    <propagate_errors>false</propagate_errors>
    <lun_storage id="360014055ff2afd2a4474cc2b44d65b0e">
        <logical_unit id="360014055ff2afd2a4474cc2b44d65b0e">
            <size>0</size>
            <paths>0</paths>
            <disk_id>85887360-4458-4536-9269-a2822b722cd9</disk_id>
        </logical_unit>
    </lun_storage>
</disk>


Luns table content:
[root@jl-rhevm32 ~]# psql  engine postgres -c "select * from luns;"
           physical_volume_id           |              lun_id               |            volume_group_id             |                             serial    
                         | lun_mapping | vendor_id | product_id | device_size 
----------------------------------------+-----------------------------------+----------------------------------------+---------------------------------------
-------------------------+-------------+-----------+------------+-------------
                                        |360014055ff2afd2a4474cc2b44d65b0e   |                                        |                                       
                         |             |           |            |           0


When user wants to remove this lun, it fails and NPE is thrown:
2013-01-31 14:56:32,697 ERROR [org.ovirt.engine.core.bll.RemoveDiskCommand] (ajp-/127.0.0.1:8702-6) [688166c0] Command org.ovirt.engine.core.bll.RemoveDiskCommand throw exception: java.lang.NullPointerException
	at org.ovirt.engine.core.bll.storage.StorageHelperBase.removeLun(StorageHelperBase.java:94) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.ImagesHandler.removeLunDisk(ImagesHandler.java:695) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.RemoveDiskCommand$1.runInTransaction(RemoveDiskCommand.java:297) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.RemoveDiskCommand$1.runInTransaction(RemoveDiskCommand.java:294) [engine-bll.jar:]
	at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInNewTransaction(TransactionSupport.java:202) [engine-utils.jar:]
	at org.ovirt.engine.core.bll.RemoveDiskCommand.removeLunDisk(RemoveDiskCommand.java:294) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.RemoveDiskCommand.executeCommand(RemoveDiskCommand.java:289) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.CommandBase.executeWithoutTransaction(CommandBase.java:1002) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.CommandBase.executeActionInTransactionScope(CommandBase.java:1087) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.CommandBase.runInTransaction(CommandBase.java:1468) [engine-bll.jar:]
	at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInSuppressed(TransactionSupport.java:166) [engine-utils.jar:]
	at org.ovirt.engine.core.utils.transaction.TransactionSupport.executeInScope(TransactionSupport.java:108) [engine-utils.jar:]
	at org.ovirt.engine.core.bll.CommandBase.execute(CommandBase.java:1105) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.CommandBase.executeAction(CommandBase.java:302) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.Backend.runActionImpl(Backend.java:359) [engine-bll.jar:]
	at org.ovirt.engine.core.bll.Backend.RunAction(Backend.java:305) [engine-bll.jar:]
	at sun.reflect.GeneratedMethodAccessor192.invoke(Unknown Source) [:1.7.0_11-icedtea]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) [rt.jar:1.7.0_11-icedtea]
	at java.lang.reflect.Method.invoke(Method.java:601) [rt.jar:1.7.0_11-icedtea]

Version-Release number of selected component (if applicable):
rhevm-restapi-3.2.0-5.el6ev.noarch

How reproducible:
Always

Steps to Reproduce:
1. Create direct lun via API
2. Remove direct lun

Additional info:
We had similar (same?) issue on 3.1: bug 863101
Backend log attached

Comment 2 Liron Aravot 2013-02-06 12:33:20 UTC
http://gerrit.ovirt.org/#/c/10630/

solved by this patch, basically the luns are getting with "" in the volume group id from gui and with null from REST -
this patch solved another issue, but solves this one as well..
will backport it.

Comment 3 Liron Aravot 2013-02-06 13:15:01 UTC
forgot to mention - in addition, a db script should be introduced to update previous luns volume group value to avoid the problem from occuring with previously added luns.

Comment 4 Katarzyna Jachim 2013-04-08 10:11:07 UTC
Verified manually on 3.2.0-10.17.master.el6ev that adding disks with REST API works correctly.

Comment 5 Itamar Heim 2013-06-11 09:07:53 UTC
3.2 has been released

Comment 6 Itamar Heim 2013-06-11 09:07:53 UTC
3.2 has been released

Comment 7 Itamar Heim 2013-06-11 09:07:54 UTC
3.2 has been released

Comment 8 Itamar Heim 2013-06-11 09:36:29 UTC
3.2 has been released