aboutsummaryrefslogtreecommitdiffstats
path: root/config-provisioning
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2023-01-22 15:13:07 +0100
committerGitHub <noreply@github.com>2023-01-22 15:13:07 +0100
commit45577c7d7d2c70637d63f89702c3229df312edc3 (patch)
tree77d7095ffeb6a631ee701546a8f0b18735bf47bd /config-provisioning
parent85bb4e8d16ec06bba6c3b45ea7cb1f084f5e988d (diff)
parent1d5806f068309e18b70fee03b7a22e111c180607 (diff)
Merge pull request #25667 from vespa-engine/bratseth/group-size
Support a group size constraint in content clusters
Diffstat (limited to 'config-provisioning')
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java36
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java5
-rw-r--r--config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java12
3 files changed, 39 insertions, 14 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
index e63750e0e11..993ab686675 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Capacity.java
@@ -1,6 +1,8 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
+import com.yahoo.collections.IntRange;
+
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;
@@ -15,12 +17,19 @@ public final class Capacity {
/** Resources should stay between these values, inclusive */
private final ClusterResources min, max;
+ private final IntRange groupSize;
private final boolean required;
private final boolean canFail;
private final NodeType type;
private final Optional<CloudAccount> cloudAccount;
- private Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type, Optional<CloudAccount> cloudAccount) {
+ private Capacity(ClusterResources min,
+ ClusterResources max,
+ IntRange groupSize,
+ boolean required,
+ boolean canFail,
+ NodeType type,
+ Optional<CloudAccount> cloudAccount) {
validate(min);
validate(max);
if (max.smallerThan(min))
@@ -30,6 +39,7 @@ public final class Capacity {
throw new IllegalArgumentException("Capacity range does not allow GPU, got min " + min + " and max " + max);
this.min = min;
this.max = max;
+ this.groupSize = groupSize;
this.required = required;
this.canFail = canFail;
this.type = type;
@@ -45,6 +55,7 @@ public final class Capacity {
public ClusterResources minResources() { return min; }
public ClusterResources maxResources() { return max; }
+ public IntRange groupSize() { return groupSize; }
/** Returns whether the requested number of nodes must be met exactly for a request for this to succeed */
public boolean isRequired() { return required; }
@@ -69,7 +80,11 @@ public final class Capacity {
}
public Capacity withLimits(ClusterResources min, ClusterResources max) {
- return new Capacity(min, max, required, canFail, type, cloudAccount);
+ return withLimits(min, max, IntRange.empty());
+ }
+
+ public Capacity withLimits(ClusterResources min, ClusterResources max, IntRange groupSize) {
+ return new Capacity(min, max, groupSize, required, canFail, type, cloudAccount);
}
@Override
@@ -85,29 +100,34 @@ public final class Capacity {
/** Create a non-required, failable capacity request */
public static Capacity from(ClusterResources min, ClusterResources max) {
- return from(min, max, false, true);
+ return from(min, max, IntRange.empty(), false, true, Optional.empty());
}
public static Capacity from(ClusterResources resources, boolean required, boolean canFail) {
return from(resources, required, canFail, NodeType.tenant);
}
- // TODO(mpolden): Remove when config models < 7.590 are gone
+ // TODO: Remove after February 2023
public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail) {
- return from(min, max, required, canFail, Optional.empty());
+ return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, Optional.empty());
}
+ // TODO: Remove after February 2023
public static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) {
- return new Capacity(min, max, required, canFail, NodeType.tenant, cloudAccount);
+ return new Capacity(min, max, IntRange.empty(), required, canFail, NodeType.tenant, cloudAccount);
+ }
+
+ public static Capacity from(ClusterResources min, ClusterResources max, IntRange groupSize, boolean required, boolean canFail, Optional<CloudAccount> cloudAccount) {
+ return new Capacity(min, max, groupSize, required, canFail, NodeType.tenant, cloudAccount);
}
/** Creates this from a node type */
public static Capacity fromRequiredNodeType(NodeType type) {
- return from(new ClusterResources(0, 0, NodeResources.unspecified()), true, false, type);
+ return from(new ClusterResources(0, 1, NodeResources.unspecified()), true, false, type);
}
private static Capacity from(ClusterResources resources, boolean required, boolean canFail, NodeType type) {
- return new Capacity(resources, resources, required, canFail, type, Optional.empty());
+ return new Capacity(resources, resources, IntRange.empty(), required, canFail, type, Optional.empty());
}
}
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java
index 9938823768b..5511a9ed1ed 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/ClusterResources.java
@@ -21,7 +21,7 @@ public class ClusterResources {
public ClusterResources(int nodes, int groups, NodeResources nodeResources) {
this.nodes = nodes;
- this.groups = groups;
+ this.groups = groups == 0 ? 1 : groups; // TODO: Throw on groups == 0 after February 2023
this.nodeResources = Objects.requireNonNull(nodeResources);
}
@@ -73,9 +73,8 @@ public class ClusterResources {
@Override
public boolean equals(Object o) {
if (o == this) return true;
- if ( ! (o instanceof ClusterResources)) return false;
+ if ( ! (o instanceof ClusterResources other)) return false;
- ClusterResources other = (ClusterResources)o;
if (other.nodes != this.nodes) return false;
if (other.groups != this.groups) return false;
if ( ! other.nodeResources.equals(this.nodeResources)) return false;
diff --git a/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java b/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java
index a6ddb401b2f..ca552003f7a 100644
--- a/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java
+++ b/config-provisioning/src/test/java/com/yahoo/config/provision/CapacityTest.java
@@ -1,8 +1,11 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.provision;
+import com.yahoo.collections.IntRange;
import org.junit.jupiter.api.Test;
+import java.util.Optional;
+
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
@@ -15,8 +18,11 @@ public class CapacityTest {
void testCapacityValidation() {
// Equal min and max is allowed
Capacity.from(new ClusterResources(4, 2, new NodeResources(1, 2, 3, 4)),
- new ClusterResources(4, 2, new NodeResources(1, 2, 3, 4)),
- false, true);
+ new ClusterResources(4, 2, new NodeResources(1, 2, 3, 4)),
+ IntRange.empty(),
+ false,
+ true,
+ Optional.empty());
assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1, 2, 3, 4)),
new ClusterResources(2, 2, new NodeResources(1, 2, 3, 4)));
assertValidationFailure(new ClusterResources(4, 4, new NodeResources(1, 2, 3, 4)),
@@ -36,7 +42,7 @@ public class CapacityTest {
private void assertValidationFailure(ClusterResources min, ClusterResources max) {
try {
- Capacity.from(min, max, false, true);
+ Capacity.from(min, max, IntRange.empty(), false, true, Optional.empty());
fail("Expected exception with min " + min + " and max " + max);
}
catch (IllegalArgumentException e) {