summaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@oath.com>2018-08-22 11:27:09 +0200
committerHarald Musum <musum@oath.com>2018-08-22 11:27:09 +0200
commit1e6fbda2d6f9866d1c089c7f46ef842484f606d6 (patch)
tree3087bc32a7dcdb16599d689e5cbaff4b6c8eef24 /configserver
parent6464389e9f980ee1a8d71a075262039939ae1094 (diff)
Handle deployment when there are no allocated hosts (bootstrapping a zone)
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java3
-rw-r--r--configserver/src/test/apps/hosted-routing-app/services.xml21
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java27
3 files changed, 50 insertions, 1 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
index 98e42b88e6d..15834a9eaa0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
@@ -168,8 +168,9 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> {
// Make sure we build wanted version if we are building models for this major version and we are on hosted vespa
// If not on hosted vespa, we do not want to try to build this version, since we have only one version (the latest)
+ // Also handle the case where there are no allocated hosts in the zone, so versions is empty
Version wanted = Version.fromIntValues(wantedVersion.getMajor(), wantedVersion.getMinor(), wantedVersion.getMicro());
- if (hosted && wantedVersion.getMajor() == findLatest(versions).getMajor())
+ if (hosted && (versions.isEmpty() || wantedVersion.getMajor() == findLatest(versions).getMajor()))
versions.add(wanted);
return versions;
diff --git a/configserver/src/test/apps/hosted-routing-app/services.xml b/configserver/src/test/apps/hosted-routing-app/services.xml
new file mode 100644
index 00000000000..3d6680b8165
--- /dev/null
+++ b/configserver/src/test/apps/hosted-routing-app/services.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
+<services version="1.0">
+
+ <admin version="3.0">
+ <nodes count='1'/>
+ </admin>
+
+ <jdisc version="1.0">
+ <http>
+ <filtering>
+ <access-control domain="foo" write="true" />
+ </filtering>
+ <server id="foo" port="4080" />
+ </http>
+ <search/>
+ <nodes type='host'/>
+ </jdisc>
+
+
+</services>
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
index a184a461ce1..02059513dff 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/HostedDeployTest.java
@@ -120,6 +120,29 @@ public class HostedDeployTest {
assertTrue("Newest is always included", factory720.creationCount() > 0);
}
+ /**
+ * Test that deploying an application works when there are no allocated hosts in the system
+ * (the bootstrap a new zone case, so deploying the routing app since that is the first deployment
+ * that will be done)
+ **/
+ @Test
+ public void testCreateOnlyNeededModelVersionsWhenNoHostsAllocated() {
+ List<Host> hosts = Collections.singletonList(createHost("host1"));
+ InMemoryProvisioner provisioner = new InMemoryProvisioner(new Hosts(hosts), true);
+ ManualClock clock = new ManualClock("2016-10-09T00:00:00");
+
+ CountingModelFactory factory700 = DeployTester.createModelFactory(Version.fromString("7.0.0"), clock);
+ CountingModelFactory factory720 = DeployTester.createModelFactory(Version.fromString("7.2.0"), clock);
+ List<ModelFactory> modelFactories = new ArrayList<>();
+ modelFactories.add(factory700);
+ modelFactories.add(factory720);
+
+ DeployTester tester = new DeployTester(modelFactories, createConfigserverConfig(),
+ clock, new Zone(Environment.dev, RegionName.defaultName()), provisioner);
+ tester.deployApp("src/test/apps/hosted-routing-app/", "myApp", "7.2.0", Instant.now());
+ assertTrue("Newest is always included", factory720.creationCount() > 0);
+ }
+
@Test
public void testAccessControlIsOnlyCheckedWhenNoProdDeploymentExists() {
// Provisioner does not reuse hosts, so need twice as many hosts as app requires
@@ -195,4 +218,8 @@ public class HostedDeployTest {
return new Host(hostname, Collections.emptyList(), Optional.empty(), Optional.of(com.yahoo.component.Version.fromString(version)));
}
+ private Host createHost(String hostname) {
+ return new Host(hostname, Collections.emptyList(), Optional.empty(), Optional.empty());
+ }
+
}