Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1641326

Summary: NPE while querying for an ancestor image with no entry on 'images' table
Product: [oVirt] ovirt-engine Reporter: shani <sleviim>
Component: BLL.StorageAssignee: Tal Nisan <tnisan>
Status: CLOSED CURRENTRELEASE QA Contact: Avihai <aefrat>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 4.3.0CC: bugs
Target Milestone: ovirt-4.2.8Flags: rule-engine: ovirt-4.2+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.2.8.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-01-22 10:23:33 UTC 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
NullPointerException on GetAncestorImagesByImagesIdsQuery by using toMap() none

Description shani 2018-10-21 08:40:55 UTC
Created attachment 1496131 [details]
NullPointerException on GetAncestorImagesByImagesIdsQuery by using toMap()

Description of problem:
In case of trying to move a disk which its ancestor image doesn't have an entry on 'images' table), the query 'GetAncestorImagesByImagesIdsQuery' returns a null DiskImage as the image's ancestor.
Using Collectors.toMap(), and receiving the null object mentioned above as the map's ValueMapper function causes to a NullPionterException.

Version-Release number of selected component (if applicable):
master-e60d148b70f

How reproducible:
100%

Steps to Reproduce:
1. Create a VM with a disk attached.
2. Take a snapshot for that VM.
3. From images table, delete the entry of the image's ancestor.
4. Try to move VM's the disk.

Actual results:
Should be no error on the engine

Expected results:
[org.ovirt.engine.core.bll.storage.disk.image.GetAncestorImagesByImagesIdsQuery]  Exception: java.lang.NullPointerException

Additional info:
engine.log

Comment 1 Avihai 2018-11-21 13:44:19 UTC
Verified on upstream ovirt-engine 4.2.8-0.0.master.20181119152157.gita72a684.

Details:

Engine log after GetAncestorImagesByImagesIdsQuery :
- Opened UI move disk window resulted in :
2018-11-21 15:32:10,918+02 WARN  [org.ovirt.engine.core.bll.storage.disk.image.GetAncestorImagesByImagesIdsQuery] (default task-18) [e047f1f3-3c3e-4259-9012-77e029d65162] Ancestor is missing for the following image id(s): 65e2975b-66f1-4c94-9537-81dd7faec400


- Base/Ancestor volume/image ID = 9a28b5c9-d660-4004-9190-862f8a3ef038 :
>engine=# select * from images;

-[ RECORD 30 ]--------+-------------------------------------
image_guid            | 9a28b5c9-d660-4004-9190-862f8a3ef038
creation_date         | 2018-11-21 15:19:44+02
size                  | 1073741824
it_guid               | 00000000-0000-0000-0000-000000000000
parentid              | 00000000-0000-0000-0000-000000000000
imagestatus           | 1
lastmodified          | 2018-11-21 15:19:58.494+02
vm_snapshot_id        | 8a418feb-4227-4ea9-b85e-403c06a6b290
volume_type           | 2
volume_format         | 4
image_group_id        | 34b069e7-3c46-44fd-ab7e-18b3700b1b72
_create_date          | 2018-11-21 15:19:41.169706+02
_update_date          | 2018-11-21 15:19:58.495286+02
active                | f
volume_classification | 1
qcow_compat           | 2


- Created new snapshot , new volume created imageID = 65e2975b-66f1-4c94-9537-81dd7faec400 :
-[ RECORD 31 ]--------+-------------------------------------
image_guid            | 65e2975b-66f1-4c94-9537-81dd7faec400
creation_date         | 2018-11-21 15:20:04+02
size                  | 1073741824
it_guid               | 00000000-0000-0000-0000-000000000000
parentid              | 9a28b5c9-d660-4004-9190-862f8a3ef038
imagestatus           | 1
lastmodified          | 1970-01-01 02:00:00+02
vm_snapshot_id        | 315683b4-e966-4310-b74b-0ca7795d57bf
volume_type           | 2
volume_format         | 4
image_group_id        | 34b069e7-3c46-44fd-ab7e-18b3700b1b72
_create_date          | 2018-11-21 15:19:58.495286+02
_update_date          | 2018-11-21 15:20:19.247328+02
active                | t
volume_classification | 0
qcow_compat           | 2



3. From images table, delete the entry of the image's ancestor.
DELETE from images WHERE image_guid='9a28b5c9-d660-4004-9190-862f8a3ef038';

Comment 2 Raz Tamir 2018-11-28 15:30:08 UTC
QE verification bot: the bug was verified upstream

Comment 3 Sandro Bonazzola 2019-01-22 10:23:33 UTC
This bugzilla is included in oVirt 4.2.8 release, published on January 22nd 2019.

Since the problem described in this bug report should be
resolved in oVirt 4.2.8 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.