Allon Mureinik has posted comments on this change.

Change subject: core: Requesting to consume quota while extending a disk fix.
......................................................................


Patch Set 2: Code-Review-1

(3 comments)

https://gerrit.ovirt.org/#/c/39330/2/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java
File 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java:

Line 689:             boolean emptyOldQuota = oldDiskImage.getQuotaId() == null 
|| Guid.Empty.equals(oldDiskImage.getQuotaId());
Line 690:             boolean differentNewQuota = !emptyOldQuota && 
!oldDiskImage.getQuotaId().equals(newDiskImage.getQuotaId());
Line 691:             long diskExtendingDiff = 
newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes();
Line 692: 
Line 693:             if (emptyOldQuota || differentNewQuota ) {
Actually, the fact that the old quota was empty seems inconsequential.

If old != new, we should consume quota from the new one and release from the 
old one. If either of them is empty, the underlying infra should just ignore it.

If old == new, we should just consume the diff from the existing quota, and 
again - if its empty, the underlying infra should ignore it.
Line 694:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
newDiskImage.getSizeInGigabytes()));
Line 695:             } else if (diskExtendingDiff != 0) {
Line 696:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
diskExtendingDiff));
Line 697:             }


https://gerrit.ovirt.org/#/c/39330/2/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java
File 
backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/UpdateVmDiskCommandTest.java:

Line 697:         initializeCommand(parameters);
Line 698: 
Line 699:         QuotaStorageConsumptionParameter consumptionParameter =
Line 700:                 (QuotaStorageConsumptionParameter) 
command.getQuotaStorageConsumptionParameters().get(0);
Line 701:         assertTrue(consumptionParameter.getRequestedStorageGB() == 
diskExtendingDiffInGB);
use assertEquals instead
Line 702:     }
Line 703: 
Line 704:     private long getBytesByGB(long sizeInGB) {
Line 705:         return sizeInGB*(1024*1024*1024);


Line 701:         assertTrue(consumptionParameter.getRequestedStorageGB() == 
diskExtendingDiffInGB);
Line 702:     }
Line 703: 
Line 704:     private long getBytesByGB(long sizeInGB) {
Line 705:         return sizeInGB*(1024*1024*1024);
Use org.ovirt.engine.core.common.utils.SizeConverter - its in the common 
package, so a bll test can use it.
Line 706:     }
Line 707: 
Line 708:     private void mockToUpdateDiskVm(List<VM> vms) {
Line 709:         for (VM vm: vms) {


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

Gerrit-MessageType: comment
Gerrit-Change-Id: Ib31206b0a9172b35217845b01253951d93f380f1
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Amit Aviram <aavi...@redhat.com>
Gerrit-Reviewer: Adam Litke <ali...@redhat.com>
Gerrit-Reviewer: Ala Hino <ah...@redhat.com>
Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com>
Gerrit-Reviewer: Amit Aviram <aavi...@redhat.com>
Gerrit-Reviewer: Candace Sheremeta <csher...@redhat.com>
Gerrit-Reviewer: Daniel Erez <de...@redhat.com>
Gerrit-Reviewer: Freddy Rolland <froll...@redhat.com>
Gerrit-Reviewer: Greg Padgett <gpadg...@redhat.com>
Gerrit-Reviewer: Idan Shaby <ish...@redhat.com>
Gerrit-Reviewer: Liron Aravot <lara...@redhat.com>
Gerrit-Reviewer: Tal Nisan <tni...@redhat.com>
Gerrit-Reviewer: Vered Volansky <vvola...@redhat.com>
Gerrit-Reviewer: automat...@ovirt.org
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to