summaryrefslogtreecommitdiffstats
path: root/node-repository
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2021-07-02 14:01:12 +0200
committerJon Bratseth <bratseth@gmail.com>2021-07-02 14:01:12 +0200
commit20b64ddac655eb9902a8cde04963c5bbbd322515 (patch)
tree068739268d48ce2191146b35e0d4433dd8fc4049 /node-repository
parentcdd064896786130b692c9a6a677c3092902f1d88 (diff)
Prefer local disk on content clusters
Diffstat (limited to 'node-repository')
-rw-r--r--node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java9
-rw-r--r--node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java33
2 files changed, 38 insertions, 4 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java
index b465917e9c9..b799e0056f3 100644
--- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java
+++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/AllocatableClusterResources.java
@@ -107,8 +107,13 @@ public class AllocatableClusterResources {
}
public boolean preferableTo(AllocatableClusterResources other) {
- if (this.fulfilment < 1 || other.fulfilment < 1)
- return this.fulfilment > other.fulfilment; // we always want to fulfil as much as possible
+ if (this.fulfilment < 1 || other.fulfilment < 1) // always fulfil as much as possible
+ return this.fulfilment > other.fulfilment;
+
+ if (clusterSpec.type().isContent() // always prefer local storage on content nodes
+ && this.realResources.storageType() != other.realResources().nodeResources().storageType())
+ return this.realResources.storageType() == NodeResources.StorageType.local;
+
return this.cost() < other.cost(); // otherwise, prefer lower cost
}
diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
index 6f1e2630434..0b7b9f2fa13 100644
--- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
+++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/DynamicProvisioningTest.java
@@ -364,7 +364,7 @@ public class DynamicProvisioningTest {
}
@Test
- public void test_any_disk_prefers_remote() {
+ public void test_any_disk_prefers_remote_for_container() {
int memoryTax = 3;
int localDiskTax = 55;
// Disk tax is not included in flavor resources but memory tax is
@@ -383,7 +383,7 @@ public class DynamicProvisioningTest {
tester.activateTenantHosts();
ApplicationId app1 = ProvisioningTester.applicationId("app1");
- ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.content, new ClusterSpec.Id("cluster1")).vespaVersion("7").build();
+ ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.container, new ClusterSpec.Id("cluster1")).vespaVersion("7").build();
tester.activate(app1, cluster1, Capacity.from(resources(4, 2, 2, 10, 200, fast, StorageType.any),
resources(6, 3, 3, 25, 400, fast, StorageType.any)));
@@ -392,6 +392,35 @@ public class DynamicProvisioningTest {
app1, cluster1);
}
+ @Test
+ public void test_any_disk_prefers_local_for_content() {
+ int memoryTax = 3;
+ int localDiskTax = 55;
+ // Disk tax is not included in flavor resources but memory tax is
+ List<Flavor> flavors = List.of(new Flavor("2x", new NodeResources(2, 20 - memoryTax, 200, 0.1, fast, local)),
+ new Flavor("4x", new NodeResources(4, 40 - memoryTax, 400, 0.1, fast, local)),
+ new Flavor("2xl", new NodeResources(2, 20 - memoryTax, 200, 0.1, fast, remote)),
+ new Flavor("4xl", new NodeResources(4, 40 - memoryTax, 400, 0.1, fast, remote)));
+
+ ProvisioningTester tester = new ProvisioningTester.Builder().zone(zone)
+ .flavors(flavors)
+ .hostProvisioner(new MockHostProvisioner(flavors, memoryTax))
+ .nameResolver(nameResolver)
+ .resourcesCalculator(memoryTax, localDiskTax)
+ .build();
+
+ tester.activateTenantHosts();
+
+ ApplicationId app1 = ProvisioningTester.applicationId("app1");
+ ClusterSpec cluster1 = ClusterSpec.request(ClusterSpec.Type.content, new ClusterSpec.Id("cluster1")).vespaVersion("7").build();
+
+ tester.activate(app1, cluster1, Capacity.from(resources(4, 2, 2, 10, 200, fast, StorageType.any),
+ resources(6, 3, 3, 25, 400, fast, StorageType.any)));
+ tester.assertNodes("'any' selects a flavor with local storage",
+ 6, 2, 2, 20, 200, fast, local,
+ app1, cluster1);
+ }
+
private void prepareAndActivate(ApplicationId application, ClusterSpec clusterSpec, int nodes, int groups, NodeResources resources) {
List<HostSpec> prepared = tester.prepare(application, clusterSpec, nodes, groups, resources);
NodeList provisionedHosts = tester.nodeRepository().nodes().list(Node.State.provisioned).nodeType(NodeType.host);