aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-07-11 13:04:51 +0200
committerMartin Polden <mpolden@mpolden.no>2022-07-11 13:04:51 +0200
commit8a4f0fa8f3a5a21a012c4533e63ae326106e00c4 (patch)
tree38f4579aa42ae2e4da41388ff3fb17139c1c23e1 /config-model/src/main/java/com/yahoo
parentf97130213c9a2546788a5e5a6299cdbbd7fee94e (diff)
Include current and required quota in quota validation messages
Diffstat (limited to 'config-model/src/main/java/com/yahoo')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java17
1 files changed, 8 insertions, 9 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java
index e4a64e8d476..7ea582b99e6 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java
@@ -84,22 +84,21 @@ public class QuotaValidator extends Validator {
}
}
- private void throwIfBudgetNegative(double spend, BigDecimal budget, SystemName systemName) {
+ private static void throwIfBudgetNegative(double spend, BigDecimal budget, SystemName systemName) {
if (budget.doubleValue() < 0) {
- throwBudgetException("Please free up some capacity! This deployment's quota use is ($%.2f) and reserved quota is below zero! ($%.2f)", spend, budget, systemName);
+ throw new IllegalArgumentException(quotaMessage("Please free up some capacity", systemName, spend, budget));
}
}
- private void throwIfBudgetExceeded(double spend, BigDecimal budget, SystemName systemName) {
+ private static void throwIfBudgetExceeded(double spend, BigDecimal budget, SystemName systemName) {
if (budget.doubleValue() < spend) {
- throw new IllegalArgumentException((systemName.equals(SystemName.Public) ? "" : systemName.value() + ": ") +
- "Deployment would make your tenant exceed its quota and has been blocked! Please contact support to update your plan.");
+ throw new IllegalArgumentException(quotaMessage("Deployment exceeds its quota and has been blocked! Please contact support to update your plan", systemName, spend, budget));
}
}
- private void throwBudgetException(String formatMessage, double spend, BigDecimal budget, SystemName systemName) {
- var message = String.format(Locale.US, formatMessage, spend, budget);
- var messageWithSystem = (systemName.equals(SystemName.Public) ? "" : systemName.value() + ": ") + message;
- throw new IllegalArgumentException(messageWithSystem);
+ private static String quotaMessage(String message, SystemName system, double spend, BigDecimal budget) {
+ String quotaDescription = String.format(Locale.ENGLISH, "Quota is $%.2f, but at least $%.2f is required", budget, spend);
+ return (system == SystemName.Public ? "" : system.value() + ": ") + message + ": " + quotaDescription;
}
+
}