Omer Frenkel has uploaded a new change for review. Change subject: core: fix vm pools behavior when DC is missing ......................................................................
core: fix vm pools behavior when DC is missing When DC is missing (for example force-removed) then if any vm pools still exist, they don't return in queries, because of bad join in the view. this was fixed by changing the vm_pools_view to use left-join with storage-pools in addition, this should not happen, as empty vm pools are not supported. but when using force-remove DC, all vms are deleted, but vm-pools are left. this was fixed by changing the stored procedure for remove storage pool, to remove vm-pools as well, after removing vms. Change-Id: I47c963b6b66efa05e96cb9b9f80e034d8070a30b Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1031717 Signed-off-by: Omer Frenkel <ofren...@redhat.com> --- M packaging/dbscripts/create_views.sql M packaging/dbscripts/storages_sp.sql 2 files changed, 11 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/24130/1 diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index c2ac599..58bba2f 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -836,7 +836,7 @@ vm_pools.spice_proxy as spice_proxy FROM vm_pools JOIN vds_groups ON vm_pools.vds_group_id = vds_groups.vds_group_id - JOIN storage_pool ON storage_pool.id = vds_groups.storage_pool_id; + LEFT JOIN storage_pool ON storage_pool.id = vds_groups.storage_pool_id; diff --git a/packaging/dbscripts/storages_sp.sql b/packaging/dbscripts/storages_sp.sql index 6866bcd..168cb19 100644 --- a/packaging/dbscripts/storages_sp.sql +++ b/packaging/dbscripts/storages_sp.sql @@ -119,6 +119,16 @@ WHERE storage_pool_id = v_id); delete FROM vm_static where vm_guid in (select vm_guid from vms where storage_pool_id = v_id); + -- Delete vm pools as empty pools are not supported + -- Get (and keep) a shared lock with "right to upgrade to exclusive" + select vm_pool_id INTO v_val FROM vm_pools where vm_pool_id in (select vm_pool_id from vm_pools_view where storage_pool_id = v_id) FOR UPDATE; + DELETE + FROM vm_pools + WHERE vm_pool_id IN ( + SELECT vm_pool_id + FROM vm_pools_view + WHERE storage_pool_id = v_id); + -- Get (and keep) a shared lock with "right to upgrade to exclusive" -- in order to force locking parent before children select id INTO v_val FROM storage_pool WHERE id = v_id FOR UPDATE; -- To view, visit http://gerrit.ovirt.org/24130 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I47c963b6b66efa05e96cb9b9f80e034d8070a30b Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Omer Frenkel <ofren...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches