summaryrefslogtreecommitdiffstats
path: root/config-model/src
diff options
context:
space:
mode:
authorØyvind Grønnesby <oyving@yahooinc.com>2022-07-11 15:03:41 +0200
committerGitHub <noreply@github.com>2022-07-11 15:03:41 +0200
commit76639f48aa145d9c188dc0995de4ec1077ab892a (patch)
treeb40a91053262f68e033144ab60ecce60f8b3a513 /config-model/src
parentb9ec181c10b73352a0d39b5c06b7033f8b4e226d (diff)
parent8a4f0fa8f3a5a21a012c4533e63ae326106e00c4 (diff)
Merge pull request #23452 from vespa-engine/mpolden/better-quota-messages
Include current and required quota in quota validation messages
Diffstat (limited to 'config-model/src')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/QuotaValidator.java17
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java8
2 files changed, 12 insertions, 13 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;
}
+
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
index 8750d3caa47..5e746d462b5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
@@ -47,7 +47,7 @@ public class QuotaValidatorTest {
tester.deploy(null, getServices("testCluster", 10), Environment.prod, null);
fail();
} catch (RuntimeException e) {
- assertEquals("Deployment would make your tenant exceed its quota and has been blocked! Please contact support to update your plan.", e.getMessage());
+ assertEquals("Deployment exceeds its quota and has been blocked! Please contact support to update your plan: Quota is $1.25, but at least $1.63 is required", e.getMessage());
}
}
@@ -58,7 +58,7 @@ public class QuotaValidatorTest {
tester.deploy(null, getServices("testCluster", 10), Environment.prod, null);
fail();
} catch (RuntimeException e) {
- assertEquals("publiccd: Deployment would make your tenant exceed its quota and has been blocked! Please contact support to update your plan.", e.getMessage());
+ assertEquals("publiccd: Deployment exceeds its quota and has been blocked! Please contact support to update your plan: Quota is $1.00, but at least $1.63 is required", e.getMessage());
}
}
@@ -69,7 +69,7 @@ public class QuotaValidatorTest {
tester.deploy(null, getServices("testCluster", 10), Environment.prod, null);
fail();
} catch (RuntimeException e) {
- assertEquals("publiccd: Deployment would make your tenant exceed its quota and has been blocked! Please contact support to update your plan.", e.getMessage());
+ assertEquals("publiccd: Deployment exceeds its quota and has been blocked! Please contact support to update your plan: Quota is $1.25, but at least $1.63 is required", e.getMessage());
}
}
@@ -82,7 +82,7 @@ public class QuotaValidatorTest {
tester.deploy(null, getServices("testCluster", 10), Environment.prod, null);
fail();
} catch (RuntimeException e) {
- assertEquals("Please free up some capacity! This deployment's quota use is ($-.--) and reserved quota is below zero! ($--.--)",
+ assertEquals("Please free up some capacity: Quota is $--.--, but at least $-.-- is required",
ValidationTester.censorNumbers(e.getMessage()));
}
}