diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2020-04-03 16:19:30 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2020-04-03 16:19:30 +0200 |
commit | 397ec35628315bb4a6a297981d4cdd6e755afaf8 (patch) | |
tree | 73af889188d867b7969799c8a9ead25467902089 | |
parent | c71a0d31e17889623a939e06cf729b8efa6bec42 (diff) |
Propagate any new non-scaled settings
4 files changed, 44 insertions, 7 deletions
diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceIterator.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceIterator.java index bc14ca1779c..b7d5995884e 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceIterator.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/autoscale/ResourceIterator.java @@ -134,7 +134,12 @@ public class ResourceIterator { } } - return allocation.realResources().withVcpu(cpu).withMemoryGb(memory).withDiskGb(disk); + // Combine the scaled resource values computed here + // and the currently combined values of non-scaled resources + return new NodeResources(cpu, memory, disk, + cluster.minResources().nodeResources().bandwidthGbps(), + cluster.minResources().nodeResources().diskSpeed(), + cluster.minResources().nodeResources().storageType()); } private double clusterUsage(Resource resource, double load) { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java index c92f7889496..d96282f1722 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeAllocation.java @@ -100,7 +100,6 @@ class NodeAllocation { List<Node> accepted = new ArrayList<>(); for (PrioritizableNode node : nodesPrioritized) { Node offered = node.node; - if (offered.allocation().isPresent()) { ClusterMembership membership = offered.allocation().get().membership(); if ( ! offered.allocation().get().owner().equals(application)) continue; // wrong application diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java index 8bfb17c0bd4..497a2a31ce5 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTest.java @@ -31,16 +31,18 @@ public class AutoscalingTest { @Test public void testAutoscalingSingleContentGroup() { - NodeResources resources = new NodeResources(3, 100, 100, 1); - ClusterResources min = new ClusterResources( 2, 1, new NodeResources(1, 1, 1, 1)); - ClusterResources max = new ClusterResources(20, 1, new NodeResources(100, 1000, 1000, 1)); - AutoscalingTester tester = new AutoscalingTester(resources); + NodeResources hostResources = new NodeResources(3, 100, 100, 1); + ClusterResources min = new ClusterResources( 2, 1, + new NodeResources(1, 1, 1, 1, NodeResources.DiskSpeed.any)); + ClusterResources max = new ClusterResources(20, 1, + new NodeResources(100, 1000, 1000, 1, NodeResources.DiskSpeed.any)); + AutoscalingTester tester = new AutoscalingTester(hostResources); ApplicationId application1 = tester.applicationId("application1"); ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.content, "cluster1"); // deploy - tester.deploy(application1, cluster1, 5, 1, resources); + tester.deploy(application1, cluster1, 5, 1, hostResources); assertTrue("No measurements -> No change", tester.autoscale(application1, cluster1.id(), min, max).isEmpty()); @@ -69,6 +71,35 @@ public class AutoscalingTest { tester.autoscale(application1, cluster1.id(), min, max)); } + @Test + public void testAutoscalingHandlesDiskSettingChanges() { + NodeResources hostResources = new NodeResources(3, 100, 100, 1, NodeResources.DiskSpeed.slow); + AutoscalingTester tester = new AutoscalingTester(hostResources); + + ApplicationId application1 = tester.applicationId("application1"); + ClusterSpec cluster1 = tester.clusterSpec(ClusterSpec.Type.content, "cluster1"); + + // deploy with slow + tester.deploy(application1, cluster1, 5, 1, hostResources); + tester.nodeRepository().getNodes(application1).stream() + .allMatch(n -> n.allocation().get().requestedResources().diskSpeed() == NodeResources.DiskSpeed.slow); + + tester.addMeasurements(Resource.cpu, 0.25f, 1f, 120, application1); + // Changing min and max from slow to any + ClusterResources min = new ClusterResources( 2, 1, + new NodeResources(1, 1, 1, 1, NodeResources.DiskSpeed.any)); + ClusterResources max = new ClusterResources(20, 1, + new NodeResources(100, 1000, 1000, 1, NodeResources.DiskSpeed.any)); + AllocatableClusterResources scaledResources = tester.assertResources("Scaling up since resource usage is too high", + 15, 1, 1.3, 28.6, 28.6, + tester.autoscale(application1, cluster1.id(), min, max)); + assertEquals("Disk speed from min/max is used", + NodeResources.DiskSpeed.any, scaledResources.realResources().diskSpeed()); + tester.deploy(application1, cluster1, scaledResources); + tester.nodeRepository().getNodes(application1).stream() + .allMatch(n -> n.allocation().get().requestedResources().diskSpeed() == NodeResources.DiskSpeed.any); + } + /** We prefer fewer nodes for container clusters as (we assume) they all use the same disk and memory */ @Test public void testAutoscalingSingleContainerGroup() { diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java index ebc4d158ded..aed262b6c96 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/autoscale/AutoscalingTester.java @@ -206,6 +206,8 @@ class AutoscalingTester { flavor.minMainMemoryAvailableGb(resources.memoryGb()); flavor.minDiskAvailableGb(resources.diskGb()); flavor.bandwidth(resources.bandwidthGbps() * 1000); + flavor.fastDisk(resources.diskSpeed().compatibleWith(NodeResources.DiskSpeed.fast)); + flavor.remoteStorage(resources.storageType().compatibleWith(NodeResources.StorageType.remote)); return flavor; } |