Change in ovirt-engine[ovirt-engine-4.1]: restapi: Don't use GetAllDisksByVmId

From Tal Nisan <tnisan@redhat.com>:
Tal Nisan has submitted this change and it was merged. Change subject: restapi: Don't use GetAllDisksByVmId ...................................................................... restapi: Don't use GetAllDisksByVmId Currently when version 3 of the API is used to request the disks of a virtual machine, the API uses the GetAllDisksByVmId query, which in turn uses the GetDisksbyVmGuid stored procedure to retrive the disks. In addition this query, for each disk, calls the GetSnapshotByLeafGuid stored procedure, to retrieve snapshot details, and the GetDiskVmElementVyDiskVmElementId, to get attachment details. The GetSnapshotByLeafGuid stored procedure is complex, and consumes a important amount of database time. Version 4 of the API uses lighter stored procedures. This patch changes the V3 compatibility layer of the API so that it calls the V4 disk attachments and disk resources instead of using the GetAllDisksByVmId query. In an otherwise idle enviroment with approxy 4000 virtual machines this reduces the total use of CPU (85% database + 15% engine) from 57 minutes to 14 minutes. This can be reproduced using the following Ruby script, which uses the 'ovirt' gem to retrieve the virtual machines and their disks: require 'active_support/all' require 'ovirt' service = Ovirt::Service.new( server: 'rhvm41.local', port: 443, domain: 'internal', username: 'admin', password: '...', verify_ssl: false, timeout: 1.hour ) vms = Ovirt::Vm.all(service) vms.each do |vm| vm.disks.each do |disk| puts "#{vm[:name]}: #{disk[:name]}" end end service.disconnect Change-Id: I4429aadb4c33271c6ba10752cd3502ceb1d2329e Bug-Url: https://bugzilla.redhat.com/1431578 Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com> (cherry picked from commit 85779a0ab4bf5fbdb1f343963f101c314afbd70a) --- M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/v3/helpers/V3VmHelper.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/v3/servers/V3VmDiskServer.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/v3/servers/V3VmDisksServer.java 3 files changed, 68 insertions(+), 38 deletions(-) Approvals: Juan Hernandez: Verified Jenkins CI: Passed CI tests Oved Ourfali: Looks good to me, approved -- To view, visit https://gerrit.ovirt.org/74009 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I4429aadb4c33271c6ba10752cd3502ceb1d2329e Gerrit-PatchSet: 2 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-4.1 Gerrit-Owner: Juan Hernandez <juan.hernandez@redhat.com> Gerrit-Reviewer: Jenkins CI Gerrit-Reviewer: Juan Hernandez <juan.hernandez@redhat.com> Gerrit-Reviewer: Oved Ourfali <oourfali@redhat.com> Gerrit-Reviewer: Tal Nisan <tnisan@redhat.com> Gerrit-Reviewer: gerrit-hooks <automation@ovirt.org>
participants (1)
-
Code Review