Allon Mureinik has posted comments on this change.

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


Patch Set 2:

(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 687:             DiskImage newDiskImage = (DiskImage) getNewDisk();
Line 688: 
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();
> if the user insert new size lower then the old size, you'll attempt to cons
We don't support reducing size, but you're right - although I don't see any 
reason to handle this now, there's no reason to assume it won't happen and 
allow bad values to be passed to the infra - see below.
Line 692: 
Line 693:             if (emptyOldQuota || differentNewQuota ) {
Line 694:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
newDiskImage.getSizeInGigabytes()));
Line 695:             } else if (diskExtendingDiff != 0) {


Line 691:             long diskExtendingDiff = 
newDiskImage.getSizeInGigabytes() - oldDiskImage.getSizeInGigabytes();
Line 692: 
Line 693:             if (emptyOldQuota || differentNewQuota ) {
Line 694:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
newDiskImage.getSizeInGigabytes()));
Line 695:             } else if (diskExtendingDiff != 0) {
Continuing Liron's comment from above, let's use ">" instead of "!=", just to 
be on the safe side. Also, because diskExtendingDiff is a long, let's use the 
proper literal:

  } else if (diskExtendingDiff > 0L) {
Line 696:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
diskExtendingDiff));
Line 697:             }
Line 698: 
Line 699:             if (differentNewQuota) {


Line 692: 
Line 693:             if (emptyOldQuota || differentNewQuota ) {
Line 694:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
newDiskImage.getSizeInGigabytes()));
Line 695:             } else if (diskExtendingDiff != 0) {
Line 696:                 list.add(generateQuotaConsumeParameters(newDiskImage, 
diskExtendingDiff));
> what if there is no quota defined for the disk? (getQuotaId() == nul)
This already happens before this patch. Note that in the existing code we'd 
always attempt to consume quota if "oldDiskImage.getQuotaId() == null || 
Guid.Empty.equals(oldDiskImage.getQuotaId());".

This status should only happen if the quota mode is disabled, which is handled 
by the backend. If there's a problem with that, it would be system wide, and 
should be handled outside the scope of this patch.
Line 697:             }
Line 698: 
Line 699:             if (differentNewQuota) {
Line 700:                 list.add(new QuotaStorageConsumptionParameter(


-- 
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 <[email protected]>
Gerrit-Reviewer: Adam Litke <[email protected]>
Gerrit-Reviewer: Ala Hino <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Amit Aviram <[email protected]>
Gerrit-Reviewer: Candace Sheremeta <[email protected]>
Gerrit-Reviewer: Daniel Erez <[email protected]>
Gerrit-Reviewer: Freddy Rolland <[email protected]>
Gerrit-Reviewer: Greg Padgett <[email protected]>
Gerrit-Reviewer: Idan Shaby <[email protected]>
Gerrit-Reviewer: Liron Aravot <[email protected]>
Gerrit-Reviewer: Roy Golan <[email protected]>
Gerrit-Reviewer: Tal Nisan <[email protected]>
Gerrit-Reviewer: Vered Volansky <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to