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

Code Review gerrit at ovirt.org
Mon Mar 13 18:52:02 UTC 2017


>From Juan Hernandez <juan.hernandez at redhat.com>:

Juan Hernandez 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 at redhat.com>
---
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
  Allon Mureinik: Looks good to me, but someone else must approve
  Oved Ourfali: Looks good to me, approved



-- 
To view, visit https://gerrit.ovirt.org/73904
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I4429aadb4c33271c6ba10752cd3502ceb1d2329e
Gerrit-PatchSet: 6
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Allon Mureinik <amureini at redhat.com>
Gerrit-Reviewer: Eldad Marciano <emarcian at redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Juan Hernandez <juan.hernandez at redhat.com>
Gerrit-Reviewer: Moti Asayag <masayag at redhat.com>
Gerrit-Reviewer: Oved Ourfali <oourfali at redhat.com>
Gerrit-Reviewer: Tal Nisan <tnisan at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the Engine-commits mailing list