summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-10-12 08:11:59 +0200
committerJon Bratseth <bratseth@gmail.com>2020-10-12 08:11:59 +0200
commit0c006afda8be00c251cfe05dfa2d2d0d0b5aa286 (patch)
tree1b059caaa8947c4d662e0b12455c6246c2df1818 /config-model
parent982a1b1804b8773be2c5db13535fa0b0e33928b1 (diff)
Defer changes until restart
In container clusters, if it is determined that a restart is required to swicth to a new config generation, mark that config as applicable only after a restart. This avoids wasting resources on a config change just before a restart, and the potential of prematurely applying config changes which depend on other changes which are not effective before a restart has been done.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java31
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContainerRestartValidator.java3
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java20
-rwxr-xr-xconfig-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java5
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/admin/DedicatedAdminV4Test.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java6
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ClusterSizeReductionValidatorTest.java10
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ResourcesReductionValidatorTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartChangesDefersConfigChangesTest.java48
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/search/ImplicitIndexingClusterTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java2
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java1
19 files changed, 106 insertions, 57 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
index 4c6dccebae4..4302a4dcd48 100644
--- a/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
+++ b/config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java
@@ -48,6 +48,9 @@ public class InMemoryProvisioner implements HostProvisioner {
/** Hosts which should be returned as retired */
private final Set<String> retiredHostNames;
+ /** If false, nodes returned will have the resources of the host, if true node resources will be as requested */
+ private final boolean sharedHosts;
+
/** Free hosts of each resource size */
private final ListMap<NodeResources, Host> freeNodes = new ListMap<>();
private final Map<ClusterSpec, List<HostSpec>> allocations = new LinkedHashMap<>();
@@ -63,33 +66,34 @@ public class InMemoryProvisioner implements HostProvisioner {
private Provisioned provisioned = new Provisioned();
/** Creates this with a number of nodes with resources 1, 3, 9, 1 */
- public InMemoryProvisioner(int nodeCount) {
- this(nodeCount, defaultResources);
+ public InMemoryProvisioner(int nodeCount, boolean sharedHosts) {
+ this(nodeCount, defaultResources, sharedHosts);
}
/** Creates this with a number of nodes with given resources */
- public InMemoryProvisioner(int nodeCount, NodeResources resources) {
- this(Map.of(resources, createHostInstances(nodeCount)), true, false, 0);
+ public InMemoryProvisioner(int nodeCount, NodeResources resources, boolean sharedHosts) {
+ this(Map.of(resources, createHostInstances(nodeCount)), true, false, sharedHosts, 0);
}
/** Creates this with a set of host names of the flavor 'default' */
- public InMemoryProvisioner(boolean failOnOutOfCapacity, String... hosts) {
- this(Map.of(defaultResources, toHostInstances(hosts)), failOnOutOfCapacity, false, 0);
+ public InMemoryProvisioner(boolean failOnOutOfCapacity, boolean sharedHosts, String... hosts) {
+ this(Map.of(defaultResources, toHostInstances(hosts)), failOnOutOfCapacity, false, sharedHosts, 0);
}
/** Creates this with a set of hosts of the flavor 'default' */
- public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, String ... retiredHostNames) {
- this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, 0, retiredHostNames);
+ public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, boolean sharedHosts, String ... retiredHostNames) {
+ this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, sharedHosts, 0, retiredHostNames);
}
/** Creates this with a set of hosts of the flavor 'default' */
- public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, int startIndexForClusters, String ... retiredHostNames) {
- this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, startIndexForClusters, retiredHostNames);
+ public InMemoryProvisioner(Hosts hosts, boolean failOnOutOfCapacity, boolean sharedHosts, int startIndexForClusters, String ... retiredHostNames) {
+ this(Map.of(defaultResources, hosts.asCollection()), failOnOutOfCapacity, false, sharedHosts, startIndexForClusters, retiredHostNames);
}
public InMemoryProvisioner(Map<NodeResources, Collection<Host>> hosts,
boolean failOnOutOfCapacity,
boolean useMaxResources,
+ boolean sharedHosts,
int startIndexForClusters,
String ... retiredHostNames) {
this.failOnOutOfCapacity = failOnOutOfCapacity;
@@ -97,8 +101,9 @@ public class InMemoryProvisioner implements HostProvisioner {
for (Map.Entry<NodeResources, Collection<Host>> hostsWithResources : hosts.entrySet())
for (Host host : hostsWithResources.getValue())
freeNodes.put(hostsWithResources.getKey(), host);
- this.retiredHostNames = Set.of(retiredHostNames);
+ this.sharedHosts = sharedHosts;
this.startIndexForClusters = startIndexForClusters;
+ this.retiredHostNames = Set.of(retiredHostNames);
}
private static Collection<Host> toHostInstances(String[] hostnames) {
@@ -160,6 +165,7 @@ public class InMemoryProvisioner implements HostProvisioner {
if (retiredHostNames.contains(host.hostname()))
i.set(retire(host));
}
+
return allocation;
}
@@ -212,8 +218,9 @@ public class InMemoryProvisioner implements HostProvisioner {
Host newHost = freeNodes.removeValue(hostResources.get(), 0);
if (freeNodes.get(hostResources.get()).isEmpty()) freeNodes.removeAll(hostResources.get());
ClusterMembership membership = ClusterMembership.from(clusterGroup, nextIndex++);
+ NodeResources resources = sharedHosts ? requestedResources : hostResources.get();
allocation.add(new HostSpec(newHost.hostname(),
- hostResources.get(), hostResources.get(), requestedResources,
+ resources, resources, requestedResources,
membership,
newHost.version(), Optional.empty(),
Optional.empty()));
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
index cc4653fc183..d300e31c3dc 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/Validation.java
@@ -117,11 +117,11 @@ public class Validation {
for (var clusterToRestart : clustersToBeRestarted) {
var containerCluster = model.getContainerClusters().get(clusterToRestart.value());
if (containerCluster != null)
- containerCluster.deferChangesUntilRestart();
+ containerCluster.setDeferChangesUntilRestart(true);
var contentCluster = model.getContentClusters().get(clusterToRestart.value());
if (contentCluster != null)
- contentCluster.deferChangesUntilRestart();
+ contentCluster.setDeferChangesUntilRestart(true);
}
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContainerRestartValidator.java b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContainerRestartValidator.java
index 17e4f031f3e..4f9ffc95ab0 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContainerRestartValidator.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/application/validation/change/ContainerRestartValidator.java
@@ -7,7 +7,6 @@ import com.yahoo.container.QrConfig;
import com.yahoo.vespa.model.VespaModel;
import com.yahoo.config.application.api.ValidationOverrides;
import com.yahoo.vespa.model.container.ApplicationContainer;
-import com.yahoo.vespa.model.container.ApplicationContainerCluster;
import com.yahoo.vespa.model.container.Container;
import com.yahoo.vespa.model.container.ContainerCluster;
@@ -16,8 +15,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
-import static java.util.stream.Collectors.toList;
-
/**
* Returns a restart action for each container that has turned on {@link QrConfig#restartOnDeploy()}.
*
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
index ca4140fe5c5..1d991721ea7 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/Container.java
@@ -58,6 +58,9 @@ public abstract class Container extends AbstractService implements
public static final int BASEPORT = Defaults.getDefaults().vespaWebServicePort();
public static final String SINGLENODE_CONTAINER_SERVICESPEC = "default_singlenode_container";
+ /** The cluster this contasiner belongs to, or null if it is not added to any cluster */
+ private ContainerCluster owner = null;
+
protected final AbstractConfigProducer parent;
private final String name;
private boolean requireSpecificPorts = true;
@@ -94,6 +97,8 @@ public abstract class Container extends AbstractService implements
addChild(new SimpleComponent("com.yahoo.container.jdisc.ConfiguredApplication$ApplicationContext"));
}
+ void setOwner(ContainerCluster<?> owner) { this.owner = owner; }
+
/** True if this container is retired (slated for removal) */
public boolean isRetired() { return retired; }
@@ -296,17 +301,14 @@ public abstract class Container extends AbstractService implements
@Override
public void getConfig(QrConfig.Builder builder) {
- builder.
- rpc(new Rpc.Builder()
+ builder.rpc(new Rpc.Builder()
.enabled(rpcServerEnabled())
.port(getRpcPort())
- .slobrokId(serviceSlobrokId())).
- filedistributor(filedistributorConfig());
- if (clusterName != null) {
- builder.discriminator(clusterName + "." + name);
- } else {
- builder.discriminator(name);
- }
+ .slobrokId(serviceSlobrokId()))
+ .filedistributor(filedistributorConfig())
+ .discriminator((clusterName != null ? clusterName + "." : "" ) + name)
+ .restartOnDeploy(owner != null && owner.getDeferChangesUntilRestart());
+
}
/** Returns the jvm args set explicitly for this node */
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
index 2d7d49f03ed..0bafd3cfdcf 100755
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/ContainerCluster.java
@@ -147,7 +147,7 @@ public abstract class ContainerCluster<CONTAINER extends Container>
private final ComponentGroup<Component<?, ?>> componentGroup;
private final boolean isHostedVespa;
- private Map<String, String> concreteDocumentTypes = new LinkedHashMap<>();
+ private final Map<String, String> concreteDocumentTypes = new LinkedHashMap<>();
private ApplicationMetaData applicationMetaData = null;
@@ -158,6 +158,8 @@ public abstract class ContainerCluster<CONTAINER extends Container>
private String jvmGCOptions = null;
private String environmentVars = null;
+ private boolean deferChangesUntilRestart = false;
+
public ContainerCluster(AbstractConfigProducer<?> parent, String configSubId, String clusterId, DeployState deployState) {
super(parent, configSubId);
this.name = clusterId;
@@ -288,6 +290,7 @@ public abstract class ContainerCluster<CONTAINER extends Container>
}
public void addContainer(CONTAINER container) {
+ container.setOwner(this);
container.setClusterName(name);
container.setProp("clustername", name)
.setProp("index", this.containers.size());
@@ -618,11 +621,13 @@ public abstract class ContainerCluster<CONTAINER extends Container>
protected abstract boolean messageBusEnabled();
/**
- * Mark that the config emitted by this cluster currently should be applied by clients already running with
+ * Mark whether the config emitted by this cluster currently should be applied by clients already running with
* a previous generation of it only by restarting the consuming processes.
*/
- public void deferChangesUntilRestart() {
-
+ public void setDeferChangesUntilRestart(boolean deferChangesUntilRestart) {
+ this.deferChangesUntilRestart = deferChangesUntilRestart;
}
+ public boolean getDeferChangesUntilRestart() { return deferChangesUntilRestart; }
+
}
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
index 1a994cd4636..66a96690dab 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/content/cluster/ContentCluster.java
@@ -744,11 +744,10 @@ public class ContentCluster extends AbstractConfigProducer implements
}
/**
- * Mark that the config emitted by this cluster currently should be applied by clients already running with
+ * Mark whether the config emitted by this cluster currently should be applied by clients already running with
* a previous generation of it only by restarting the consuming processes.
*/
- public void deferChangesUntilRestart() {
-
+ public void setDeferChangesUntilRestart(boolean deferChangesUntilRestart) {
}
}
diff --git a/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java b/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
index d243a2dacf6..594f5a13546 100644
--- a/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java
@@ -38,7 +38,7 @@ public class DeployStateTest {
@Test
public void testProvisionerIsSet() {
DeployState.Builder builder = new DeployState.Builder();
- HostProvisioner provisioner = new InMemoryProvisioner(true, "foo.yahoo.com");
+ HostProvisioner provisioner = new InMemoryProvisioner(true, false, "foo.yahoo.com");
builder.modelHostProvisioner(provisioner);
DeployState state = builder.build();
assertThat(state.getProvisioner(), is(provisioner));
diff --git a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
index 26d8a9b0eca..e3a53c8c4f1 100644
--- a/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
+++ b/config-model/src/test/java/com/yahoo/config/model/provision/ModelProvisioningTest.java
@@ -103,7 +103,7 @@ public class ModelProvisioningTest {
+ " </host>"
+ "</hosts>";
VespaModelCreatorWithMockPkg creator = new VespaModelCreatorWithMockPkg(null, services);
- VespaModel model = creator.create(new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(new StringReader(hosts)), true)));
+ VespaModel model = creator.create(new DeployState.Builder().modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(new StringReader(hosts)), true, false)));
ApplicationContainerCluster mydisc = model.getContainerClusters().get("mydisc");
ApplicationContainerCluster mydisc2 = model.getContainerClusters().get("mydisc2");
assertEquals(3, mydisc.getContainers().size());
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/admin/DedicatedAdminV4Test.java b/config-model/src/test/java/com/yahoo/vespa/model/admin/DedicatedAdminV4Test.java
index 71dc1564277..f1f794c5057 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/admin/DedicatedAdminV4Test.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/admin/DedicatedAdminV4Test.java
@@ -236,7 +236,7 @@ public class DedicatedAdminV4Test {
.build();
return new VespaModel(new NullConfigModelRegistry(), deployStateBuilder
.applicationPackage(app)
- .modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(app.getHosts()), true))
+ .modelHostProvisioner(new InMemoryProvisioner(Hosts.readFrom(app.getHosts()), true, false))
.build());
}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
index 9eb3f9b8541..12f0c7013e5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/QuotaValidatorTest.java
@@ -20,13 +20,13 @@ public class QuotaValidatorTest {
@Test
public void test_deploy_under_quota() {
- var tester = new ValidationTester(5, new TestProperties().setHostedVespa(true).setQuota(quota));
+ var tester = new ValidationTester(5, false, new TestProperties().setHostedVespa(true).setQuota(quota));
tester.deploy(null, getServices("testCluster", 5), Environment.prod, null);
}
@Test
public void test_deploy_above_quota_clustersize() {
- var tester = new ValidationTester(11, new TestProperties().setHostedVespa(true).setQuota(quota));
+ var tester = new ValidationTester(11, false, new TestProperties().setHostedVespa(true).setQuota(quota));
try {
tester.deploy(null, getServices("testCluster", 11), Environment.prod, null);
fail();
@@ -37,7 +37,7 @@ public class QuotaValidatorTest {
@Test
public void test_deploy_above_quota_budget() {
- var tester = new ValidationTester(10, new TestProperties().setHostedVespa(true).setQuota(quota));
+ var tester = new ValidationTester(10, false, new TestProperties().setHostedVespa(true).setQuota(quota));
try {
tester.deploy(null, getServices("testCluster", 10), Environment.prod, null);
fail();
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
index 2b3b1a9fcc7..b7fa72d8a64 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/ValidationTester.java
@@ -40,8 +40,8 @@ public class ValidationTester {
}
/** Creates a validation tester with number of nodes available and the given test properties */
- public ValidationTester(int nodeCount, TestProperties properties) {
- this(new InMemoryProvisioner(nodeCount), properties);
+ public ValidationTester(int nodeCount, boolean sharedHosts, TestProperties properties) {
+ this(new InMemoryProvisioner(nodeCount, sharedHosts), properties);
}
/** Creates a validation tester with a given host provisioner */
@@ -51,7 +51,7 @@ public class ValidationTester {
/** Creates a validation tester with a number of nodes available */
public ValidationTester(int nodeCount) {
- this(new InMemoryProvisioner(nodeCount), new TestProperties().setHostedVespa(true));
+ this(new InMemoryProvisioner(nodeCount, false), new TestProperties().setHostedVespa(true));
}
/** Creates a validation tester with a given host provisioner */
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ClusterSizeReductionValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ClusterSizeReductionValidatorTest.java
index 87684aca174..bade5a746f7 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ClusterSizeReductionValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ClusterSizeReductionValidatorTest.java
@@ -43,16 +43,6 @@ public class ClusterSizeReductionValidatorTest {
tester.deploy(previous, getServices(2), Environment.prod, null);
}
- /*
- @Test
- public void testSizeReductionTo50PercentIsAllowed() throws IOException, SAXException {
- ValidationTester tester = new ValidationTester(30);
-
- VespaModel previous = tester.deploy(null, getServices(30), null).getFirst();
- tester.deploy(previous, getServices(15), null);
- }
- */
-
@Test
public void testOverridingSizereductionValidation() {
ValidationTester tester = new ValidationTester(30);
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ResourcesReductionValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ResourcesReductionValidatorTest.java
index 9a363789798..920e69e614b 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ResourcesReductionValidatorTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/ResourcesReductionValidatorTest.java
@@ -19,7 +19,7 @@ import static org.junit.Assert.fail;
*/
public class ResourcesReductionValidatorTest {
- private final InMemoryProvisioner provisioner = new InMemoryProvisioner(30, new NodeResources(64, 128, 1000, 10));
+ private final InMemoryProvisioner provisioner = new InMemoryProvisioner(30, new NodeResources(64, 128, 1000, 10), false);
private final ValidationTester tester = new ValidationTester(provisioner);
@Test
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartChangesDefersConfigChangesTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartChangesDefersConfigChangesTest.java
new file mode 100644
index 00000000000..35aa9a3c988
--- /dev/null
+++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/change/RestartChangesDefersConfigChangesTest.java
@@ -0,0 +1,48 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.model.application.validation.change;
+
+import com.yahoo.config.model.provision.InMemoryProvisioner;
+import com.yahoo.config.provision.Environment;
+import com.yahoo.config.provision.NodeResources;
+import com.yahoo.container.QrConfig;
+import com.yahoo.vespa.model.VespaModel;
+import com.yahoo.vespa.model.application.validation.ValidationTester;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author bratseth
+ */
+public class RestartChangesDefersConfigChangesTest {
+
+ @Test
+ public void changes_requiring_restart_defers_config_changes() {
+ ValidationTester tester = new ValidationTester(new InMemoryProvisioner(5,
+ new NodeResources(1, 3, 9, 1),
+ true));
+ VespaModel gen1 = tester.deploy(null, getServices(5, 3), Environment.prod, null).getFirst();
+
+ // Change node count - no restart
+ VespaModel gen2 = tester.deploy(gen1, getServices(4, 3), Environment.prod, null).getFirst();
+ var config2 = new QrConfig.Builder();
+ gen2.getContainerClusters().get("default").getContainers().get(0).getConfig(config2);
+ assertFalse(config2.build().restartOnDeploy());
+
+ // Change memory amount - requires restart
+ VespaModel gen3 = tester.deploy(gen2, getServices(4, 2), Environment.prod, null).getFirst();
+ var config3 = new QrConfig.Builder();
+ gen3.getContainerClusters().get("default").getContainers().get(0).getConfig(config3);
+ assertTrue(config3.build().restartOnDeploy());
+ }
+
+ private static String getServices(int nodes, int memory) {
+ return "<services version='1.0'>" +
+ " <container id='default' version='1.0'>" +
+ " <nodes count='" + nodes + "'><resources vcpu='1' memory='" + memory + "Gb' disk='9Gb'/></nodes>" +
+ " </container>" +
+ "</services>";
+ }
+
+}
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/search/ImplicitIndexingClusterTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/search/ImplicitIndexingClusterTest.java
index c7118618003..2d48f55d3d5 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/search/ImplicitIndexingClusterTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/search/ImplicitIndexingClusterTest.java
@@ -50,7 +50,7 @@ public class ImplicitIndexingClusterTest {
ModelContext.Properties properties = new TestProperties().setMultitenant(true).setHostedVespa(true);
DeployState.Builder deployStateBuilder = new DeployState.Builder()
.properties(properties)
- .modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com", "host3.yahoo.com"));
+ .modelHostProvisioner(new InMemoryProvisioner(true, false, "host1.yahoo.com", "host2.yahoo.com", "host3.yahoo.com"));
return new VespaModelCreatorWithMockPkg(new MockApplicationPackage.Builder()
.withServices("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + servicesXml)
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
index 7195a762478..f8046bfe92d 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java
@@ -618,7 +618,7 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
String servicesXml = "<container id='default' version='1.0' />";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder().withServices(servicesXml).build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder()
- .modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com", "host2.yahoo.com"))
+ .modelHostProvisioner(new InMemoryProvisioner(true, false, "host1.yahoo.com", "host2.yahoo.com"))
.applicationPackage(applicationPackage)
.properties(new TestProperties()
.setMultitenant(true)
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
index b1550d90f35..297c0cebbb4 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/content/utils/ContentClusterUtils.java
@@ -46,7 +46,7 @@ public class ContentClusterUtils {
}
public static MockRoot createMockRoot(String[] hosts, List<String> schemas) {
- return createMockRoot(new InMemoryProvisioner(true, hosts), schemas);
+ return createMockRoot(new InMemoryProvisioner(true, false, hosts), schemas);
}
public static MockRoot createMockRoot(List<String> schemas) {
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
index c985ebabbf9..f5250343afe 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTestCase.java
@@ -276,7 +276,7 @@ public class VespaModelTestCase {
.build();
DeployState deployState = new DeployState.Builder()
.applicationPackage(applicationPackage)
- .modelHostProvisioner(new InMemoryProvisioner(true, "host1.yahoo.com"))
+ .modelHostProvisioner(new InMemoryProvisioner(true, false, "host1.yahoo.com"))
.properties(new TestProperties()
.setConfigServerSpecs(Arrays.asList(new TestProperties.Spec("cfghost", 1234, 1236)))
.setMultitenant(true))
diff --git a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
index cdfd9fab194..813ca4ac0cb 100644
--- a/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
+++ b/config-model/src/test/java/com/yahoo/vespa/model/test/VespaModelTester.java
@@ -138,6 +138,7 @@ public class VespaModelTester {
HostProvisioner provisioner = hosted ?
new InMemoryProvisioner(hostsByResources, failOnOutOfCapacity, useMaxResources,
+ false,
startIndexForClusters, retiredHostNames) :
new SingleNodeProvisioner();