summaryrefslogtreecommitdiffstats
path: root/config-model
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-09-25 16:02:12 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2021-09-25 16:02:12 +0200
commit0d44342bf9fa0b89b8358dddb8c9027ac4fa07a7 (patch)
treebf95ff81dbe5fc90f2384f7fda204247091c9b22 /config-model
parent799d41556bea27116fb328524c6812ff7401636e (diff)
Add featureflag control of container shutdown.
Diffstat (limited to 'config-model')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java13
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/Container.java8
-rw-r--r--config-model/src/test/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilderTest.java50
3 files changed, 50 insertions, 21 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
index 4bf20e75a5d..dea6b980692 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java
@@ -63,6 +63,8 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
private double resourceLimitDisk = 0.8;
private double resourceLimitMemory = 0.8;
private double minNodeRatioPerGroup = 0.0;
+ private boolean containerDumpHeapOnShutdownTimeout = false;
+ private double containerShutdownTimeout = 50.0;
@Override public ModelContext.FeatureFlags featureFlags() { return this; }
@Override public boolean multitenant() { return multitenant; }
@@ -106,7 +108,16 @@ public class TestProperties implements ModelContext.Properties, ModelContext.Fea
@Override public double minNodeRatioPerGroup() { return minNodeRatioPerGroup; }
@Override public int metricsproxyNumThreads() { return 1; }
@Override public boolean enforceRankProfileInheritance() { return enforceRankProfileInheritance; }
-
+ @Override public double containerShutdownTimeout() { return containerShutdownTimeout; }
+ @Override public boolean containerDumpHeapOnShutdownTimeout() { return containerDumpHeapOnShutdownTimeout; }
+ public TestProperties containerDumpHeapOnShutdownTimeout(boolean value) {
+ containerDumpHeapOnShutdownTimeout = value;
+ return this;
+ }
+ public TestProperties containerShutdownTimeout(double value) {
+ containerShutdownTimeout = value;
+ return this;
+ }
public TestProperties enforceRankProfileInheritance(boolean value) {
enforceRankProfileInheritance = value;
return this;
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 b915453b593..cdf8d592391 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
@@ -74,6 +74,8 @@ public abstract class Container extends AbstractService implements
private final boolean retired;
/** The unique index of this node */
private final int index;
+ private final boolean dumpHeapOnShutdownTimeout;
+ private final double shutdownTimeoutS;
private final ComponentGroup<Handler<?>> handlers = new ComponentGroup<>(this, "handler");
private final ComponentGroup<Component<?, ?>> components = new ComponentGroup<>(this, "components");
@@ -90,6 +92,8 @@ public abstract class Container extends AbstractService implements
this.parent = parent;
this.retired = retired;
this.index = index;
+ dumpHeapOnShutdownTimeout = deployState.featureFlags().containerDumpHeapOnShutdownTimeout();
+ shutdownTimeoutS = deployState.featureFlags().containerShutdownTimeout();
this.defaultHttpServer = new JettyHttpServer("DefaultHttpServer", containerClusterOrNull(parent), deployState.isHosted());
if (getHttp() == null) {
addChild(defaultHttpServer);
@@ -315,7 +319,9 @@ public abstract class Container extends AbstractService implements
.slobrokId(serviceSlobrokId()))
.filedistributor(filedistributorConfig())
.discriminator((clusterName != null ? clusterName + "." : "" ) + name)
- .nodeIndex(index);
+ .nodeIndex(index)
+ .shutdown.dumpHeapOnTimeout(dumpHeapOnShutdownTimeout)
+ .timeout(shutdownTimeoutS);
}
/** Returns the jvm args set explicitly for this node */
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 2505aa3b01e..912ca23dce2 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
@@ -7,6 +7,7 @@ import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.NullConfigModelRegistry;
import com.yahoo.config.model.api.ContainerEndpoint;
import com.yahoo.config.model.api.EndpointCertificateSecrets;
+import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.api.TenantSecretStore;
import com.yahoo.config.model.builder.xml.test.DomBuilderTest;
import com.yahoo.config.model.deploy.DeployState;
@@ -681,36 +682,47 @@ public class ContainerModelBuilderTest extends ContainerModelBuilderTestBase {
@Test
public void qrconfig_is_produced() throws IOException, SAXException {
+ QrConfig qr = getQrConfig(new TestProperties());
+ String hostname = HostName.getLocalhost(); // Using the same way of getting hostname as filedistribution model
+ assertEquals("default.container.0", qr.discriminator());
+ assertEquals(19102, qr.rpc().port());
+ assertEquals("vespa/service/default/container.0", qr.rpc().slobrokId());
+ assertTrue(qr.rpc().enabled());
+ assertEquals("", qr.rpc().host());
+ assertFalse(qr.restartOnDeploy());
+ assertEquals("filedistribution/" + hostname, qr.filedistributor().configid());
+ assertEquals(50.0, qr.shutdown().timeout(), 0.00000000000001);
+ assertFalse(qr.shutdown().dumpHeapOnTimeout());
+ }
+ private QrConfig getQrConfig(ModelContext.Properties properties) throws IOException, SAXException {
String servicesXml =
"<services>" +
- "<admin version='3.0'>" +
- " <nodes count='2'/>" +
- "</admin>" +
- "<container id ='default' version='1.0'>" +
- " <nodes>" +
- " <node hostalias='node1' />" +
- " </nodes>" +
- "</container>" +
- "</services>";
+ " <admin version='3.0'>" +
+ " <nodes count='2'/>" +
+ " </admin>" +
+ " <container id ='default' version='1.0'>" +
+ " <nodes>" +
+ " <node hostalias='node1' />" +
+ " </nodes>" +
+ " </container>" +
+ "</services>";
ApplicationPackage applicationPackage = new MockApplicationPackage.Builder()
.withServices(servicesXml)
.build();
VespaModel model = new VespaModel(new NullConfigModelRegistry(), new DeployState.Builder()
.applicationPackage(applicationPackage)
- .properties(new TestProperties())
+ .properties(properties)
.build());
- String hostname = HostName.getLocalhost(); // Using the same way of getting hostname as filedistribution model
+ return model.getConfig(QrConfig.class, "default/container.0");
+ }
- QrConfig config = model.getConfig(QrConfig.class, "default/container.0");
- assertEquals("default.container.0", config.discriminator());
- assertEquals(19102, config.rpc().port());
- assertEquals("vespa/service/default/container.0", config.rpc().slobrokId());
- assertTrue(config.rpc().enabled());
- assertEquals("", config.rpc().host());
- assertFalse(config.restartOnDeploy());
- assertEquals("filedistribution/" + hostname, config.filedistributor().configid());
+ @Test
+ public void control_container_shutdown() throws IOException, SAXException {
+ QrConfig qr = getQrConfig(new TestProperties().containerShutdownTimeout(133).containerDumpHeapOnShutdownTimeout(true));
+ assertEquals(133.0, qr.shutdown().timeout(), 0.00000000000001);
+ assertTrue(qr.shutdown().dumpHeapOnTimeout());
}
@Test