summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--flags/src/main/java/com/yahoo/vespa/flags/custom/ClusterCapacity.java43
-rw-r--r--flags/src/test/java/com/yahoo/vespa/flags/custom/ClusterCapacityTest.java25
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java39
3 files changed, 75 insertions, 32 deletions
diff --git a/flags/src/main/java/com/yahoo/vespa/flags/custom/ClusterCapacity.java b/flags/src/main/java/com/yahoo/vespa/flags/custom/ClusterCapacity.java
index b24d5f62174..fc5f2456a77 100644
--- a/flags/src/main/java/com/yahoo/vespa/flags/custom/ClusterCapacity.java
+++ b/flags/src/main/java/com/yahoo/vespa/flags/custom/ClusterCapacity.java
@@ -7,8 +7,8 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
-
import java.util.Objects;
+import java.util.Optional;
import java.util.OptionalDouble;
/**
@@ -23,23 +23,34 @@ public class ClusterCapacity {
private final OptionalDouble memoryGb;
private final OptionalDouble diskGb;
private final OptionalDouble bandwidthGbps;
+ private final Optional<String> diskSpeed;
+ private final Optional<String> storageType;
+ private final Optional<String> architecture;
+
@JsonCreator
public ClusterCapacity(@JsonProperty("count") int count,
@JsonProperty("vcpu") Double vcpu,
@JsonProperty("memoryGb") Double memoryGb,
@JsonProperty("diskGb") Double diskGb,
- @JsonProperty("bandwidthGbps") Double bandwidthGbps) {
+ @JsonProperty("bandwidthGbps") Double bandwidthGbps,
+ @JsonProperty("diskSpeed") String diskSpeed,
+ @JsonProperty("storageType") String storageType,
+ @JsonProperty("architecture") String architecture) {
this.count = (int) requireNonNegative("count", count);
this.vcpu = vcpu == null ? OptionalDouble.empty() : OptionalDouble.of(requireNonNegative("vcpu", vcpu));
this.memoryGb = memoryGb == null ? OptionalDouble.empty() : OptionalDouble.of(requireNonNegative("memoryGb", memoryGb));
this.diskGb = diskGb == null ? OptionalDouble.empty() : OptionalDouble.of(requireNonNegative("diskGb", diskGb));
this.bandwidthGbps = bandwidthGbps == null ? OptionalDouble.empty() : OptionalDouble.of(bandwidthGbps);
+ this.diskSpeed = Optional.ofNullable(diskSpeed);
+ this.storageType = Optional.ofNullable(storageType);
+ this.architecture = Optional.ofNullable(architecture);
}
/** Returns a new ClusterCapacity equal to {@code this}, but with the given count. */
public ClusterCapacity withCount(int count) {
- return new ClusterCapacity(count, vcpuOrNull(), memoryGbOrNull(), diskGbOrNull(), bandwidthGbpsOrNull());
+ return new ClusterCapacity(count, vcpuOrNull(), memoryGbOrNull(), diskGbOrNull(), bandwidthGbpsOrNull(),
+ diskSpeedOrNull(), storageTypeOrNull(), architectureOrNull());
}
@JsonGetter("count") public int count() { return count; }
@@ -55,13 +66,23 @@ public class ClusterCapacity {
@JsonGetter("bandwidthGbps") public Double bandwidthGbpsOrNull() {
return bandwidthGbps.isPresent() ? bandwidthGbps.getAsDouble() : null;
}
+ @JsonGetter("diskSpeed") public String diskSpeedOrNull() {
+ return diskSpeed.orElse(null);
+ }
+ @JsonGetter("storageType") public String storageTypeOrNull() {
+ return storageType.orElse(null);
+ }
+ @JsonGetter("architecture") public String architectureOrNull() {
+ return architecture.orElse(null);
+ }
@JsonIgnore public Double vcpu() { return vcpu.orElse(0.0); }
@JsonIgnore public Double memoryGb() { return memoryGb.orElse(0.0); }
@JsonIgnore public Double diskGb() { return diskGb.orElse(0.0); }
-
- @JsonIgnore
- public double bandwidthGbps() { return bandwidthGbps.orElse(1.0); }
+ @JsonIgnore public double bandwidthGbps() { return bandwidthGbps.orElse(1.0); }
+ @JsonIgnore public String diskSpeed() { return diskSpeed.orElse("fast"); }
+ @JsonIgnore public String storageType() { return storageType.orElse("any"); }
+ @JsonIgnore public String architecture() { return architecture.orElse("x86_64"); }
@Override
public String toString() {
@@ -71,6 +92,9 @@ public class ClusterCapacity {
", memoryGb=" + memoryGb +
", diskGb=" + diskGb +
", bandwidthGbps=" + bandwidthGbps +
+ ", diskSpeed=" + diskSpeed +
+ ", storageType=" + storageType +
+ ", architecture=" + architecture +
'}';
}
@@ -83,12 +107,15 @@ public class ClusterCapacity {
vcpu.equals(that.vcpu) &&
memoryGb.equals(that.memoryGb) &&
diskGb.equals(that.diskGb) &&
- bandwidthGbps.equals(that.bandwidthGbps);
+ bandwidthGbps.equals(that.bandwidthGbps) &&
+ diskSpeed.equals(that.diskSpeed) &&
+ storageType.equals(that.storageType) &&
+ architecture.equals(that.architecture);
}
@Override
public int hashCode() {
- return Objects.hash(count, vcpu, memoryGb, diskGb, bandwidthGbps);
+ return Objects.hash(count, vcpu, memoryGb, diskGb, bandwidthGbps, diskSpeed, storageType, architecture);
}
private static double requireNonNegative(String name, double value) {
diff --git a/flags/src/test/java/com/yahoo/vespa/flags/custom/ClusterCapacityTest.java b/flags/src/test/java/com/yahoo/vespa/flags/custom/ClusterCapacityTest.java
index 796cdbf30d1..471e458846b 100644
--- a/flags/src/test/java/com/yahoo/vespa/flags/custom/ClusterCapacityTest.java
+++ b/flags/src/test/java/com/yahoo/vespa/flags/custom/ClusterCapacityTest.java
@@ -12,47 +12,56 @@ public class ClusterCapacityTest {
@Test
void serialization() throws IOException {
- ClusterCapacity clusterCapacity = new ClusterCapacity(7, 1.2, 3.4, 5.6, null);
+ ClusterCapacity clusterCapacity = new ClusterCapacity(7, 1.2, 3.4, 5.6, null, "fast", "local", "x86_64");
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(clusterCapacity);
- assertEquals("{\"count\":7,\"vcpu\":1.2,\"memoryGb\":3.4,\"diskGb\":5.6}", json);
+ assertEquals("{\"count\":7,\"vcpu\":1.2,\"memoryGb\":3.4,\"diskGb\":5.6,\"diskSpeed\":\"fast\",\"storageType\":\"local\",\"architecture\":\"x86_64\"}", json);
ClusterCapacity deserialized = mapper.readValue(json, ClusterCapacity.class);
+ assertEquals(7, deserialized.count());
assertEquals(1.2, deserialized.vcpu(), 0.0001);
assertEquals(3.4, deserialized.memoryGb(), 0.0001);
assertEquals(5.6, deserialized.diskGb(), 0.0001);
assertEquals(1.0, deserialized.bandwidthGbps(), 0.0001);
- assertEquals(7, deserialized.count());
+ assertEquals("fast", deserialized.diskSpeed());
+ assertEquals("local", deserialized.storageType());
+ assertEquals("x86_64", deserialized.architecture());
}
@Test
void serialization2() throws IOException {
- ClusterCapacity clusterCapacity = new ClusterCapacity(7, 1.2, 3.4, 5.6, 2.3);
+ ClusterCapacity clusterCapacity = new ClusterCapacity(7, 1.2, 3.4, 5.6, 2.3, "any", "remote", "arm64");
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(clusterCapacity);
- assertEquals("{\"count\":7,\"vcpu\":1.2,\"memoryGb\":3.4,\"diskGb\":5.6,\"bandwidthGbps\":2.3}", json);
+ assertEquals("{\"count\":7,\"vcpu\":1.2,\"memoryGb\":3.4,\"diskGb\":5.6,\"bandwidthGbps\":2.3,\"diskSpeed\":\"any\",\"storageType\":\"remote\",\"architecture\":\"arm64\"}", json);
ClusterCapacity deserialized = mapper.readValue(json, ClusterCapacity.class);
+ assertEquals(7, deserialized.count());
assertEquals(1.2, deserialized.vcpu(), 0.0001);
assertEquals(3.4, deserialized.memoryGb(), 0.0001);
assertEquals(5.6, deserialized.diskGb(), 0.0001);
assertEquals(2.3, deserialized.bandwidthGbps(), 0.0001);
- assertEquals(7, deserialized.count());
+ assertEquals("any", deserialized.diskSpeed());
+ assertEquals("remote", deserialized.storageType());
+ assertEquals("arm64", deserialized.architecture());
}
@Test
void serializationWithNoNodeResources() throws IOException {
- ClusterCapacity clusterCapacity = new ClusterCapacity(7, null, null, null, null);
+ ClusterCapacity clusterCapacity = new ClusterCapacity(7, null, null, null, null, null, null, null);
ObjectMapper mapper = new ObjectMapper();
String json = mapper.writeValueAsString(clusterCapacity);
assertEquals("{\"count\":7}", json);
ClusterCapacity deserialized = mapper.readValue(json, ClusterCapacity.class);
+ assertEquals(7, deserialized.count());
assertEquals(0.0, deserialized.vcpu(), 0.0001);
assertEquals(0.0, deserialized.memoryGb(), 0.0001);
assertEquals(0.0, deserialized.diskGb(), 0.0001);
assertEquals(1.0, deserialized.bandwidthGbps(), 0.0001); // 1.0 is used as fallback
- assertEquals(7, deserialized.count());
+ assertEquals("fast", deserialized.diskSpeed());
+ assertEquals("any", deserialized.storageType());
+ assertEquals("x86_64", deserialized.architecture());
}
} \ No newline at end of file
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
index 375517278b2..28530ddd39a 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/maintenance/HostCapacityMaintainerTest.java
@@ -82,7 +82,7 @@ public class HostCapacityMaintainerTest {
@Test
public void does_not_deprovision_when_preprovisioning_enabled() {
var tester = new DynamicProvisioningTester().addInitialNodes();
- tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(), List.of(new ClusterCapacity(1, 1.0, 3.0, 2.0, 1.0)), ClusterCapacity.class);
+ tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(), List.of(new ClusterCapacity(1, 1.0, 3.0, 2.0, 1.0, "fast", "local", "x86_64")), ClusterCapacity.class);
Optional<Node> failedHost = tester.nodeRepository.nodes().node("host2");
assertTrue(failedHost.isPresent());
@@ -95,8 +95,8 @@ public class HostCapacityMaintainerTest {
public void provision_deficit_and_deprovision_excess() {
var tester = new DynamicProvisioningTester().addInitialNodes();
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, 48.0, 128.0, 1000.0, 10.0),
- new ClusterCapacity(1, 16.0, 24.0, 100.0, 1.0)),
+ List.of(new ClusterCapacity(2, 48.0, 128.0, 1000.0, 10.0, "fast", "local", "x86_64"),
+ new ClusterCapacity(1, 16.0, 24.0, 100.0, 1.0, "fast", "local", "x86_64")),
ClusterCapacity.class);
assertEquals(0, tester.hostProvisioner.provisionedHosts().size());
@@ -125,9 +125,9 @@ public class HostCapacityMaintainerTest {
var tester = new DynamicProvisioningTester().addInitialNodes();
// Makes provisioned hosts 48-128-1000-10
tester.hostProvisioner.overrideHostFlavor("host4");
-
+ var clusterCapacity = new ClusterCapacity(2, 1.0, 30.0, 20.0, 3.0, "fast", "local", "x86_64");
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, 1.0, 30.0, 20.0, 3.0)),
+ List.of(clusterCapacity),
ClusterCapacity.class);
assertEquals(0, tester.hostProvisioner.provisionedHosts().size());
@@ -147,10 +147,9 @@ public class HostCapacityMaintainerTest {
verifyFirstMaintain(tester);
// Add a second cluster equal to the first. It should fit on existing host3 and host100.
-
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, 1.0, 30.0, 20.0, 3.0),
- new ClusterCapacity(2, 1.0, 30.0, 20.0, 3.0)),
+ List.of(clusterCapacity,
+ clusterCapacity),
ClusterCapacity.class);
tester.maintain();
@@ -163,8 +162,8 @@ public class HostCapacityMaintainerTest {
// host3 is a 24-64-100-10 while host100 is 48-128-1000-10.
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, 1.0, 30.0, 20.0, 3.0),
- new ClusterCapacity(2, 24.0, 64.0, 100.0, 1.0)),
+ List.of(clusterCapacity,
+ new ClusterCapacity(2, 24.0, 64.0, 100.0, 1.0, "fast", "local", "x86_64")),
ClusterCapacity.class);
tester.maintain();
@@ -179,7 +178,7 @@ public class HostCapacityMaintainerTest {
// If the preprovision capacity is reduced, we should see shared hosts deprovisioned.
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(1, 1.0, 30.0, 20.0, 3.0)),
+ List.of(new ClusterCapacity(1, 1.0, 30.0, 20.0, 3.0, "fast", "local", "x86_64")),
ClusterCapacity.class);
tester.maintain();
@@ -267,7 +266,9 @@ public class HostCapacityMaintainerTest {
var tester = new DynamicProvisioningTester();
NodeResources resources1 = new NodeResources(24, 64, 100, 10);
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(), resources1.bandwidthGbps())),
+ List.of(new ClusterCapacity(2, resources1.vcpu(), resources1.memoryGb(), resources1.diskGb(),
+ resources1.bandwidthGbps(), resources1.diskSpeed().name(),
+ resources1.storageType().name(), resources1.architecture().name())),
ClusterCapacity.class);
tester.maintain();
@@ -287,7 +288,7 @@ public class HostCapacityMaintainerTest {
// Must be able to allocate 2 nodes with "no resource requirement"
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(2, 0.0, 0.0, 0.0, 0.0)),
+ List.of(new ClusterCapacity(2, 0.0, 0.0, 0.0, 0.0, null, null, null)),
ClusterCapacity.class);
// Next maintenance run does nothing
@@ -312,7 +313,7 @@ public class HostCapacityMaintainerTest {
// Increasing the capacity provisions additional hosts
tester.flagSource.withListFlag(PermanentFlags.PREPROVISION_CAPACITY.id(),
- List.of(new ClusterCapacity(3, 0.0, 0.0, 0.0, 0.0)),
+ List.of(new ClusterCapacity(3, 0.0, 0.0, 0.0, 0.0, null, null, null)),
ClusterCapacity.class);
assertEquals(0, tester.provisionedHostsMatching(sharedHostNodeResources));
assertTrue(tester.nodeRepository.nodes().node("host102").isEmpty());
@@ -329,7 +330,10 @@ public class HostCapacityMaintainerTest {
resources1.vcpu() - applicationNodeResources.vcpu(),
resources1.memoryGb() - applicationNodeResources.memoryGb(),
resources1.diskGb() - applicationNodeResources.diskGb(),
- resources1.bandwidthGbps() - applicationNodeResources.bandwidthGbps())),
+ resources1.bandwidthGbps() - applicationNodeResources.bandwidthGbps(),
+ resources1.diskSpeed().name(),
+ resources1.storageType().name(),
+ resources1.architecture().name())),
ClusterCapacity.class);
tester.assertNodesUnchanged();
@@ -339,7 +343,10 @@ public class HostCapacityMaintainerTest {
resources1.vcpu() - applicationNodeResources.vcpu() + 1,
resources1.memoryGb() - applicationNodeResources.memoryGb() + 1,
resources1.diskGb() - applicationNodeResources.diskGb() + 1,
- resources1.bandwidthGbps())),
+ resources1.bandwidthGbps(),
+ resources1.diskSpeed().name(),
+ resources1.storageType().name(),
+ resources1.architecture().name())),
ClusterCapacity.class);
assertEquals(1, tester.provisionedHostsMatching(sharedHostNodeResources));