summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/java/com/yahoo/config
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-06-26 17:38:08 +0200
committerJon Bratseth <bratseth@oath.com>2018-06-26 17:38:08 +0200
commite49550176a0a000941412f874efd95b21e424183 (patch)
treee0aaf35c2d5225caca40568b88d01f61f387792c /config-model/src/main/java/com/yahoo/config
parent31bce0b6fea68f8551045f7aca8706bae1ff060d (diff)
Don't fail on out of capacity on bootstrap
Diffstat (limited to 'config-model/src/main/java/com/yahoo/config')
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java17
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/provision/InMemoryProvisioner.java21
2 files changed, 30 insertions, 8 deletions
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java
index d3e91f8866c..b259f6cf3fb 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployProperties.java
@@ -25,6 +25,7 @@ public class DeployProperties {
private final String athenzDnsSuffix;
private final boolean hostedVespa;
private final Version vespaVersion;
+ private final boolean isBootstrap;
private DeployProperties(boolean multitenant,
ApplicationId applicationId,
@@ -33,7 +34,8 @@ public class DeployProperties {
boolean hostedVespa,
URI ztsUrl,
String athenzDnsSuffix,
- Version vespaVersion) {
+ Version vespaVersion,
+ boolean isBootstrap) {
this.loadBalancerName = loadBalancerName;
this.ztsUrl = ztsUrl;
this.athenzDnsSuffix = athenzDnsSuffix;
@@ -42,9 +44,9 @@ public class DeployProperties {
this.applicationId = applicationId;
this.serverSpecs.addAll(configServerSpecs);
this.hostedVespa = hostedVespa;
+ this.isBootstrap = isBootstrap;
}
-
public boolean multitenant() {
return multitenant;
}
@@ -78,6 +80,9 @@ public class DeployProperties {
return vespaVersion;
}
+ /** Returns whether this deployment happens during bootstrap *prepare* (not set on activate) */
+ public boolean isBootstrap() { return isBootstrap; }
+
public static class Builder {
private ApplicationId applicationId = ApplicationId.defaultId();
@@ -88,6 +93,7 @@ public class DeployProperties {
private String athenzDnsSuffix;
private boolean hostedVespa = false;
private Version vespaVersion = Version.fromIntValues(1, 0, 0);
+ private boolean isBootstrap = false;
public Builder applicationId(ApplicationId applicationId) {
this.applicationId = applicationId;
@@ -129,8 +135,13 @@ public class DeployProperties {
return this;
}
+ public Builder isBootstrap(boolean isBootstrap) {
+ this.isBootstrap = isBootstrap;
+ return this;
+ }
+
public DeployProperties build() {
- return new DeployProperties(multitenant, applicationId, configServerSpecs, loadBalancerName, hostedVespa, ztsUrl, athenzDnsSuffix, vespaVersion);
+ return new DeployProperties(multitenant, applicationId, configServerSpecs, loadBalancerName, hostedVespa, ztsUrl, athenzDnsSuffix, vespaVersion, isBootstrap);
}
}
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 e6b89d7f390..c744c509b9a 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
@@ -24,7 +24,8 @@ import java.util.Optional;
import java.util.Set;
/**
- * In memory host provisioner. NB! ATM cannot be reused after allocate has been called.
+ * In memory host provisioner for testing only.
+ * NB! ATM cannot be reused after allocate has been called.
*
* @author hmusum
* @author bratseth
@@ -97,6 +98,9 @@ public class InMemoryProvisioner implements HostProvisioner {
return hosts;
}
+ /** Returns the current allocations of this as a mutable map */
+ public Map<ClusterSpec, List<HostSpec>> allocations() { return allocations; }
+
@Override
public HostSpec allocateHost(String alias) {
if (legacyMapping.containsKey(alias)) return legacyMapping.get(alias);
@@ -129,14 +133,16 @@ public class InMemoryProvisioner implements HostProvisioner {
allocation.addAll(allocateHostGroup(cluster.with(Optional.of(ClusterSpec.Group.from(0))),
flavor,
capacity,
- startIndexForClusters));
+ startIndexForClusters,
+ requestedCapacity.canFail()));
}
else {
for (int i = 0; i < groups; i++) {
allocation.addAll(allocateHostGroup(cluster.with(Optional.of(ClusterSpec.Group.from(i))),
flavor,
capacity / groups,
- allocation.size()));
+ allocation.size(),
+ requestedCapacity.canFail()));
}
}
for (ListIterator<HostSpec> i = allocation.listIterator(); i.hasNext(); ) {
@@ -155,13 +161,18 @@ public class InMemoryProvisioner implements HostProvisioner {
host.version());
}
- private List<HostSpec> allocateHostGroup(ClusterSpec clusterGroup, String flavor, int nodesInGroup, int startIndex) {
+ private List<HostSpec> allocateHostGroup(ClusterSpec clusterGroup, String flavor, int nodesInGroup, int startIndex, boolean canFail) {
List<HostSpec> allocation = allocations.getOrDefault(clusterGroup, new ArrayList<>());
allocations.put(clusterGroup, allocation);
int nextIndex = nextIndexInCluster.getOrDefault(new Pair<>(clusterGroup.type(), clusterGroup.id()), startIndex);
while (allocation.size() < nodesInGroup) {
- if (freeNodes.get(flavor).isEmpty()) throw new IllegalArgumentException("Insufficient capacity of flavor '" + flavor + "'");
+ if (freeNodes.get(flavor).isEmpty()) {
+ if (canFail)
+ throw new IllegalArgumentException("Insufficient capacity of flavor '" + flavor + "'");
+ else
+ break;
+ }
Host newHost = freeNodes.removeValue(flavor, 0);
ClusterMembership membership = ClusterMembership.from(clusterGroup, nextIndex++);
allocation.add(new HostSpec(newHost.hostname(), newHost.aliases(), newHost.flavor(), Optional.of(membership), newHost.version()));