From af2868f0eb3f3925837cb1f53287d074df47deec Mon Sep 17 00:00:00 2001 From: Jon Bratseth Date: Mon, 18 Dec 2017 07:44:13 +0100 Subject: Revert "Revert "Disable in-place resize"" --- .../hosted/provision/provisioning/NodeSpec.java | 38 ++++++++++++---------- .../provision/provisioning/ProvisioningTest.java | 10 +++--- 2 files changed, 27 insertions(+), 21 deletions(-) (limited to 'node-repository') 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 4c6f1b022a4..23a6e3a8b9a 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 @@ -11,14 +11,14 @@ import java.util.Objects; * A specification of a set of nodes. * This reflects that nodes can be requested either by count and flavor or by type, * and encapsulates the differences in logic between these two cases. - * + * * @author bratseth */ public interface NodeSpec { /** The node type this requests */ NodeType type(); - + /** Returns whether the given flavor is compatible with this spec */ boolean isCompatible(Flavor flavor); @@ -33,15 +33,15 @@ public interface NodeSpec { /** Returns whether the given node count is sufficient to fulfill this spec */ boolean fulfilledBy(int count); - + /** Returns the amount the given count is above the minimum amount needed to fulfill this request */ int surplusGiven(int count); - + /** Returns a specification of a fraction of all the nodes of this. It is assumed the argument is a valid divisor. */ NodeSpec fraction(int divisor); - /** - * Assigns the flavor requested by this to the given node and returns it, + /** + * Assigns the flavor requested by this to the given node and returns it, * if one is requested and it is allowed to change. * Otherwise, the node is returned unchanged. */ @@ -50,17 +50,17 @@ public interface NodeSpec { static NodeSpec from(int nodeCount, Flavor flavor) { return new CountNodeSpec(nodeCount, flavor); } - + static NodeSpec from(NodeType type) { return new TypeNodeSpec(type); } - + /** A node spec specifying a node count and a flavor */ class CountNodeSpec implements NodeSpec { - + private final int count; private final Flavor requestedFlavor; - + public CountNodeSpec(int count, Flavor flavor) { Objects.requireNonNull(flavor, "A flavor must be specified"); this.count = count; @@ -79,7 +79,7 @@ public interface NodeSpec { public NodeType type() { return NodeType.tenant; } @Override - public boolean isCompatible(Flavor flavor) { + public boolean isCompatible(Flavor flavor) { if (flavor.satisfies(requestedFlavor)) return true; return requestedFlavorCanBeAchievedByResizing(flavor); } @@ -91,7 +91,7 @@ public interface NodeSpec { public boolean specifiesNonStockFlavor() { return ! requestedFlavor.isStock(); } @Override - public boolean fulfilledBy(int count) { return count >= this.count; } + public boolean fulfilledBy(int count) { return count >= this.count; } @Override public boolean saturatedBy(int count) { return fulfilledBy(count); } // min=max for count specs @@ -101,12 +101,13 @@ public interface NodeSpec { @Override public NodeSpec fraction(int divisor) { return new CountNodeSpec(count/divisor, requestedFlavor); } - + @Override public Node assignRequestedFlavor(Node node) { // Docker nodes can change flavor in place if (requestedFlavorCanBeAchievedByResizing(node.flavor())) return node.with(requestedFlavor); + return node; } @@ -115,16 +116,19 @@ public interface NodeSpec { /** Docker nodes can be downsized in place */ private boolean requestedFlavorCanBeAchievedByResizing(Flavor flavor) { - return flavor.isDocker() && requestedFlavor.isDocker() && flavor.isLargerThan(requestedFlavor); + // TODO: Enable this when we can do it safely + // Then also re-enable ProvisioningTest.application_deployment_with_inplace_downsize() + // return flavor.isDocker() && requestedFlavor.isDocker() && flavor.isLargerThan(requestedFlavor); + return false; } - + } /** A node spec specifying a node type. This will accept all nodes of this type. */ class TypeNodeSpec implements NodeSpec { - + private final NodeType type; - + public TypeNodeSpec(NodeType type) { this.type = type; } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java index afdce0d25cc..a7ea77618bb 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/provisioning/ProvisioningTest.java @@ -181,7 +181,7 @@ public class ProvisioningTest { SystemState state5 = prepare(application1, 2, 2, 3, 3, "default", tester); tester.activate(application1, state5.allHosts); assertEquals("Superfluous container nodes are also deactivated", - 4-2 + 5-2 + 1, tester.getNodes(application1, Node.State.inactive).size()); // + 4-2 + 5-2 + 1, tester.getNodes(application1, Node.State.inactive).size()); // assertEquals("Superfluous content nodes are retired", 5-3 + 6-3 - 1, tester.getNodes(application1, Node.State.active).retired().size()); @@ -231,6 +231,8 @@ public class ProvisioningTest { 0, tester.getNodes(application1, Node.State.active).retired().flavor("large").size()); } + // TODO: Enable when this feature is re-enabled + @Ignore @Test public void application_deployment_with_inplace_downsize() { ProvisioningTester tester = new ProvisioningTester(new Zone(Environment.prod, RegionName.from("us-east"))); @@ -761,7 +763,7 @@ public class ProvisioningTest { if (nodeCount == 0) return Collections.emptySet(); // this is a shady practice return new HashSet<>(tester.prepare(application, cluster, nodeCount, groups, flavor)); } - + private static class SystemState { private Set allHosts; @@ -781,7 +783,7 @@ public class ProvisioningTest { this.content0 = content0; this.content1 = content1; } - + /** Returns a host by cluster name and index, or null if there is no host with the given values in this */ public HostSpec hostByMembership(String clusterId, int group, int index) { for (HostSpec host : allHosts) { @@ -794,7 +796,7 @@ public class ProvisioningTest { } return null; } - + private boolean groupMatches(Optional clusterGroup, int group) { if ( ! clusterGroup.isPresent()) return group==0; return clusterGroup.get().index() == group; -- cgit v1.2.3