Description of problem: upgrade of QE production setup running 3.0.7 to latest SI24.4 (RC) is failing on the following: 2012-11-25 13:41:11::DEBUG::common_utils::341::root:: stderr = psql:upgrade/03_01_0440_vm_device_upgrade_data.sql:194: ERROR: insert or update on table "vm_device" violates foreign key constraint "fk_vm_device_vm _static" DETAIL: Key (vm_id)=(7cbdb1f6-e8dc-4c9b-9b60-60c1224428bf) is not present in table "vm_static". CONTEXT: SQL statement "insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_readonly) select id, vmt_guid, 'interface', 'bridge', '', null, '', true , true, false from vm_interface where vmt_guid IS NOT NULL" PL/pgSQL function "__temp_vm_device_upgrade_data" line 21 at SQL statement 2012-11-25 13:41:11::DEBUG::common_utils::342::root:: retcode = 3 2012-11-25 13:41:11::ERROR::rhevm-upgrade::1264::root:: Traceback (most recent call last): File "/usr/bin/rhevm-upgrade", line 1250, in main runFunc([db.update], MSG_INFO_DB_UPDATE) File "/usr/bin/rhevm-upgrade", line 663, in runFunc func() File "/usr/bin/rhevm-upgrade", line 601, in update output, rc = utils.execCmd(cmdList=cmd, failOnError=True, msg=MSG_ERROR_UPDATE_DB) File "/usr/share/ovirt-engine/scripts/common_utils.py", line 345, in execCmd raise Exception(msg) Exception: Error: Database update failed data-base is attached - just run upgrade script on it.
This bug is a result of missing FK between vmt_guid in vm_interface and vm_guid in vm_static. This cause junk interface left in vm_interface when a template that has interfaces is removed. Since in upgrade from 3.0 to 3.1 we added the vm_device table, there is an attempt to insert those junk interfaces to vm_device that fails on the FK constraint between vm_device and vm_static.
http://gerrit.ovirt.org/#/c/9462/
fixed in commit : cca1d99