summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreer <andreer@verizonmedia.com>2020-10-25 21:38:59 +0100
committerandreer <andreer@verizonmedia.com>2020-10-25 21:38:59 +0100
commitc2cc2823c7397c30934b40cedafe2d9d34829c4a (patch)
tree4c11f2e9d9ab80cf9c85b382801b204aadf97a4f
parent41d74ab07e9e45da22a1153176061bd186bcc0e8 (diff)
use .zones() to get all deployments
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentQuotaCalculator.java8
1 files changed, 4 insertions, 4 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentQuotaCalculator.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentQuotaCalculator.java
index 9bf04fbc4e6..82d83ea3585 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentQuotaCalculator.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/DeploymentQuotaCalculator.java
@@ -2,7 +2,6 @@ package com.yahoo.vespa.hosted.controller.application;
import com.yahoo.config.application.api.DeploymentSpec;
import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.api.integration.billing.Quota;
@@ -51,13 +50,14 @@ public class DeploymentQuotaCalculator {
.filter(app -> !app.id().equals(deployingApp))
.map(Application::quotaUsage).reduce(QuotaUsage::add).orElse(QuotaUsage.none);
- long productionInstances = Math.max(1, deploymentSpec.instances().stream()
- .filter(instance -> instance.concerns(Environment.prod))
+ long productionDeployments = Math.max(1, deploymentSpec.instances().stream()
+ .flatMap(instance -> instance.zones().stream())
+ .filter(zone -> zone.environment().isProduction())
.count());
return tenantQuota.withBudget(
tenantQuota.subtractUsage(usageOutsideApplication.rate())
- .budget().get().divide(BigDecimal.valueOf(productionInstances),
+ .budget().get().divide(BigDecimal.valueOf(productionDeployments),
5, RoundingMode.HALF_UP)); // 1/1000th of a cent should be accurate enough
}
}