summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java42
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/Flags.java11
2 files changed, 46 insertions, 7 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java
index 6f162a8275e..cae768afc90 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/billing/Quota.java
@@ -1,32 +1,64 @@
package com.yahoo.vespa.hosted.controller.api.integration.billing;
import java.util.Objects;
+import java.util.Optional;
/**
* Quota information transmitted to the configserver on deploy.
*/
public class Quota {
- private final int maxClusterSize;
+ private final Optional<Integer> maxClusterSize;
+ private final Optional<Integer> budget; // in USD/hr, as calculated by NodeResources
public Quota(int maxClusterSize) {
- this.maxClusterSize = maxClusterSize;
+ this(Optional.of(maxClusterSize), Optional.empty());
}
- public int maxClusterSize() {
+ public Quota(int maxClusterSize, int dollarsPerHour) {
+ this(Optional.of(maxClusterSize), Optional.of(dollarsPerHour));
+ }
+
+ public Quota(Optional<Integer> maxClusterSize, Optional<Integer> budget) {
+ this.maxClusterSize = Objects.requireNonNull(maxClusterSize);
+ this.budget = Objects.requireNonNull(budget);
+ }
+
+ public Optional<Integer> maxClusterSize() {
return maxClusterSize;
}
+ public Optional<Integer> budget() {
+ return budget;
+ }
+
+ public Quota withMaxClusterSize(int clusterSize) {
+ return new Quota(Optional.of(clusterSize), budget);
+ }
+
+ public Quota withBudget(int budget) {
+ return new Quota(maxClusterSize, Optional.of(budget));
+ }
+
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Quota quota = (Quota) o;
- return maxClusterSize == quota.maxClusterSize;
+ return maxClusterSize.equals(quota.maxClusterSize) &&
+ budget.equals(quota.budget);
}
@Override
public int hashCode() {
- return Objects.hash(maxClusterSize);
+ return Objects.hash(maxClusterSize, budget);
+ }
+
+ @Override
+ public String toString() {
+ return "Quota{" +
+ "maxClusterSize=" + maxClusterSize +
+ ", budget=" + budget +
+ '}';
}
}
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
index 2c847e132f0..3e326871f7c 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/Flags.java
@@ -315,8 +315,15 @@ public class Flags {
public static final UnboundIntFlag TENANT_NODE_QUOTA = defineIntFlag(
"tenant-node-quota", 5,
- "The number of nodes a tenant is allowed to request",
- "Takes effect on next deployment",
+ "The number of nodes a tenant is allowed to request per cluster",
+ "Only takes effect on next deployment, if set to a value other than the default for flag!",
+ APPLICATION_ID
+ );
+
+ public static final UnboundIntFlag TENANT_BUDGET_QUOTA = defineIntFlag(
+ "tenant-budget-quota", 5,
+ "The budget in $/hr a tenant is allowed spend per instance, as calculated by NodeResources",
+ "Only takes effect on next deployment, if set to a value other than the default for flag!",
APPLICATION_ID
);