Roy Golan has uploaded a new change for review.

Change subject: core: skip quota for flows with no storage pool
......................................................................

core: skip quota for flows with no storage pool

Quota checks are being made based on a commands "quota dependency" which
is being marked by an enum on the VdcActionType. The problem is that
some commands, e.g. AddDisk may need quota check on regular disk but not
on external floating LUN disk, mainly because this command will not have
a storage pool (floating disk doesn't belong to a data center) thus - no
quota could be calculated on it.

As a way out, instead of breaking a command to two, (one quotable and one
not) an empty list of quota params can be submitted so no quota checks
will be made.

Change-Id: Ie468db3709522653cd93c338564592e2ba439c4a
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
2 files changed, 11 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/9410/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
index 29d157d..79e3e1c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java
@@ -636,20 +636,24 @@
             return true;
         }
 
-        if (getStoragePool() == null) {
-            throw new InvalidQuotaParametersException("Command: " + 
this.getClass().getName()
-                    + ". Storage pool is not available for quota calculation. 
");
-        }
-
         QuotaConsumptionParametersWrapper quotaConsumptionParametersWrapper = 
new QuotaConsumptionParametersWrapper(this,
                 getReturnValue().getCanDoActionMessages());
         
quotaConsumptionParametersWrapper.setParameters(getQuotaConsumptionParameters());
 
-        if (quotaConsumptionParametersWrapper.getParameters() == null) {
+        List<QuotaConsumptionParameter> quotaParams = 
quotaConsumptionParametersWrapper.getParameters();
+        if (quotaParams == null) {
             throw new InvalidQuotaParametersException("Command: " + 
this.getClass().getName()
                     + ". No Quota parameters available.");
         }
 
+        // Some commands are not quotable, given the values of their 
parameters.
+        // e.g AddDisk is storage-quotable but when the disk type is external 
LUN there is no storage pool to it.
+        // scenarios like this must set its QuotaConsumptionParameter to an 
empty list.
+        if (!quotaParams.isEmpty() && getStoragePool() == null) {
+            throw new InvalidQuotaParametersException("Command: " + 
this.getClass().getName()
+                    + ". Storage pool is not available for quota calculation. 
");
+        }
+
         boolean result = 
getQuotaManager().consume(quotaConsumptionParametersWrapper);
         setQuotaChanged(result);
         return result;
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
index a85f688..41b23c9 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/quota/QuotaConsumptionParametersWrapper.java
@@ -55,9 +55,9 @@
     public QuotaConsumptionParametersWrapper clone() throws 
CloneNotSupportedException {
         QuotaConsumptionParametersWrapper cloneWrapper = new 
QuotaConsumptionParametersWrapper(getAuditLogable(),
                 canDoActionMessages);
-        cloneWrapper.setParameters(new ArrayList<QuotaConsumptionParameter>());
 
         if (getParameters() != null) {
+            cloneWrapper.setParameters(new 
ArrayList<QuotaConsumptionParameter>());
             for (QuotaConsumptionParameter parameter : getParameters()) {
                 cloneWrapper.getParameters().add(parameter.clone());
             }


--
To view, visit http://gerrit.ovirt.org/9410
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie468db3709522653cd93c338564592e2ba439c4a
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to