aboutsummaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@vespa.ai>2024-04-24 11:52:40 +0000
committerTor Brede Vekterli <vekterli@vespa.ai>2024-04-24 11:52:40 +0000
commit76d7b011171a99cb3c0e614e8b16cbe870134b24 (patch)
tree9f155261a4c0e9e8a730de9500ec03b4aa5dcdfb /config-model/src/main/java/com
parentc6685d0d0c8c25f6790cadea4e4c6daf791c57b6 (diff)
Enforce that content node distribution keys are in legal range
Diffstat (limited to 'config-model/src/main/java/com')
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java8
1 files changed, 8 insertions, 0 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
index 5ec23b53109..ba52664a660 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/ContentNode.java
@@ -37,6 +37,14 @@ public abstract class ContentNode extends AbstractService
rpc_num_targets = featureFlags.rpcNumTargets();
rpc_events_before_wakeup = featureFlags.rpcEventsBeforeWakeup();
+ // <node>-level distribution key range validation is initially done through the XML schema,
+ // but we also check it here in the case of programmatic content node instantiations.
+ // Only [0, UINT16_MAX - 1] is a valid range. UINT16_MAX is a special content layer-internal
+ // sentinel value that must never be used by actual nodes.
+ if (distributionKey < 0 || distributionKey >= 65535) {
+ throw new IllegalArgumentException("Distribution key %d is outside valid range [0, 65534]".formatted(distributionKey));
+ }
+
initialize();
setProp("clustertype", "content");
setProp("clustername", clusterName);