From 0c266792971f88d6b51a92321e7b39bf214c815b Mon Sep 17 00:00:00 2001 From: Valerij Fredriksen Date: Wed, 29 Sep 2021 20:21:42 +0200 Subject: Allow in-place resize for non-content nodes when decreasing resources and increasing cluster size --- .../provision/provisioning/NodePrioritizer.java | 1 + .../hosted/provision/provisioning/NodeSpec.java | 9 ++++---- .../provisioning/InPlaceResizeProvisionTest.java | 27 ++++++++++------------ 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java index e506216f13d..1f618a18d24 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodePrioritizer.java @@ -191,6 +191,7 @@ public class NodePrioritizer { parent.exclusiveToApplicationId().isEmpty() && requestedNodes.canResize(node.resources(), capacity.availableCapacityOf(parent), + clusterSpec.type(), topologyChange, currentClusterSize)); } else { diff --git a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java index a84f35a314b..48cfe671248 100644 --- a/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java +++ b/node-repository/src/main/java/com/yahoo/vespa/hosted/provision/provisioning/NodeSpec.java @@ -1,6 +1,7 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.hosted.provision.provisioning; +import com.yahoo.config.provision.ClusterSpec; import com.yahoo.config.provision.Flavor; import com.yahoo.config.provision.NodeFlavors; import com.yahoo.config.provision.NodeResources; @@ -72,7 +73,7 @@ public interface NodeSpec { * in-place to resources in this spec. */ default boolean canResize(NodeResources currentNodeResources, NodeResources currentSpareHostResources, - boolean hasTopologyChange, int currentClusterSize) { + ClusterSpec.Type type, boolean hasTopologyChange, int currentClusterSize) { return false; } @@ -153,12 +154,12 @@ public interface NodeSpec { @Override public boolean canResize(NodeResources currentNodeResources, NodeResources currentSpareHostResources, - boolean hasTopologyChange, int currentClusterSize) { + ClusterSpec.Type type, boolean hasTopologyChange, int currentClusterSize) { // Never allow in-place resize when also changing topology or decreasing cluster size if (hasTopologyChange || count < currentClusterSize) return false; - // Do not allow increasing cluster size and decreasing node resources at the same time - if (count > currentClusterSize && !requestedNodeResources.satisfies(currentNodeResources.justNumbers())) + // Do not allow increasing cluster size and decreasing node resources at the same time for content nodes + if (type.isContent() && count > currentClusterSize && !requestedNodeResources.satisfies(currentNodeResources.justNumbers())) return false; // Otherwise, allowed as long as the host can satisfy the new requested resources diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InPlaceResizeProvisionTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InPlaceResizeProvisionTest.java index 8f07e57a26b..06a9bc9ac12 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InPlaceResizeProvisionTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/InPlaceResizeProvisionTest.java @@ -29,20 +29,17 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; /** - * If there is no change in cluster size or topology, any increase in node resource allocation is fine as long as: - * a. We have the necessary spare resources available on the all hosts used in the cluster - * b. We have the necessary spare resources available on a subset of the hosts used in the cluster AND - * also have available capacity to migrate the remaining nodes to different hosts. - * c. Any decrease in node resource allocation is fine. + * Node resources can be increased in-place if + * 1. No change to topology + * 2. No reduction to cluster size + * 3. There is enough spare capacity on host * - * If there is an increase in cluster size, this can be combined with increase in resource allocations given there is - * available resources and new nodes. + * Node resources can be decreased in-place if + * 1. No change to topology + * 2. No reduction to cluster size + * 3. For content/combined nodes: No increase to cluster size * - * No other changes should be supported at this time, due to risks in complexity and possibly unknowns. - * Specifically, the following is intentionally not supported by the above changes: - * a. Decrease in resource allocation combined with cluster size increase - * b. Change in resource allocation combined with cluster size reduction - * c. Change in resource allocation combined with cluster topology changes + * Node resources are increased if at least one of the components (vcpu, memory, disk, bandwidth) is increased. * * @author freva */ @@ -218,10 +215,10 @@ public class InPlaceResizeProvisionTest { public void cannot_inplace_decrease_resources_while_increasing_cluster_size() { addParentHosts(6, mediumResources.with(fast).with(local)); - new PrepareHelper(tester, app).prepare(container1, 4, 1, mediumResources).activate(); - assertSizeAndResources(container1, 4, new NodeResources(4, 8, 160, 1, fast, local)); + new PrepareHelper(tester, app).prepare(content1, 4, 1, mediumResources).activate(); + assertSizeAndResources(content1, 4, new NodeResources(4, 8, 160, 1, fast, local)); - new PrepareHelper(tester, app).prepare(container1, 6, 1, smallResources); + new PrepareHelper(tester, app).prepare(content1, 6, 1, smallResources); } @Test(expected = OutOfCapacityException.class) -- cgit v1.2.3