diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-10-08 15:04:30 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-10-08 15:04:30 +0200 |
commit | f006ca3846f915aedbf0b827e22427c01203fdbe (patch) | |
tree | be8eb70c5f48bddd98fe3a5d942fc4abd4587452 /config-model | |
parent | 2bccbdbfd60eecd55f7362ff9060ee9a2eff9917 (diff) |
Only restart on memory change
Diffstat (limited to 'config-model')
2 files changed, 12 insertions, 7 deletions
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidator.java index d6731c86607..5d56a27321a 100644 --- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidator.java +++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidator.java @@ -16,7 +16,8 @@ import java.util.Optional; import java.util.stream.Collectors; /** - * Emits restart change actions for clusters where the node resources are changed. + * Emits restart change actions for clusters where the node resources are changed in a way + * which requires a "restart" (container recreation) to take effect. * Nodes will restart on their own on this condition but we want to emit restart actions to * defer applying new config until restart. * @@ -31,12 +32,16 @@ public class NodeResourceChangeValidator implements ChangeValidator { Optional<NodeResources> currentResources = resourcesOf(clusterId, current); Optional<NodeResources> nextResources = resourcesOf(clusterId, next); if (currentResources.isEmpty() || nextResources.isEmpty()) continue; // new or removed cluster - if ( ! currentResources.equals(nextResources)) + if ( changeRequiresRestart(currentResources.get(), nextResources.get())) restartActions.addAll(createRestartActionsFor(clusterId, current)); } return restartActions; } + private boolean changeRequiresRestart(NodeResources currentResources, NodeResources nextResources) { + return currentResources.memoryGb() != nextResources.memoryGb(); + } + private Optional<NodeResources> resourcesOf(ClusterSpec.Id clusterId, VespaModel model) { return model.allocatedHosts().getHosts().stream().filter(host -> host.membership().isPresent()) .filter(host -> host.membership().get().cluster().id().equals(clusterId)) diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidatorTest.java index fa4887cd8ee..ecf026e7d88 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/NodeResourceChangeValidatorTest.java @@ -61,7 +61,7 @@ public class NodeResourceChangeValidatorTest { Clock.systemUTC().instant()); } - private static VespaModel model(int vcpu1, int vcpu2, int vcpu3, int vcpu4) { + private static VespaModel model(int mem1, int mem2, int mem3, int mem4) { var properties = new TestProperties(); properties.setHostedVespa(true); var deployState = new DeployState.Builder().properties(properties) @@ -72,17 +72,17 @@ public class NodeResourceChangeValidatorTest { "<services version='1.0'>\n" + " <container id='container1' version='1.0'>\n" + " <nodes count='1'>\n" + - " <resources vcpu='" + vcpu1 + "' memory='10Gb' disk='100Gb'/>" + + " <resources vcpu='1' memory='" + mem1 + "Gb' disk='100Gb'/>" + " </nodes>\n" + " </container>\n" + " <container id='container2' version='1.0'>\n" + " <nodes count='2'>\n" + - " <resources vcpu='" + vcpu2 + "' memory='10Gb' disk='100Gb'/>" + + " <resources vcpu='1' memory='" + mem2 + "Gb' disk='100Gb'/>" + " </nodes>\n" + " </container>\n" + " <content id='content1' version='1.0'>\n" + " <nodes count='3'>\n" + - " <resources vcpu='" + vcpu3 + "' memory='10Gb' disk='100Gb'/>" + + " <resources vcpu='1' memory='" + mem3 + "Gb' disk='100Gb'/>" + " </nodes>\n" + " <documents>\n" + " <document mode='index' type='test'/>\n" + @@ -91,7 +91,7 @@ public class NodeResourceChangeValidatorTest { " </content>\n" + " <content id='content2' version='1.0'>\n" + " <nodes count='4'>\n" + - " <resources vcpu='" + vcpu4 + "' memory='10Gb' disk='100Gb'/>" + + " <resources vcpu='1' memory='" + mem4 + "Gb' disk='100Gb'/>" + " </nodes>\n" + " <documents>\n" + " <document mode='streaming' type='test'/>\n" + |