aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2019-10-11 13:16:35 +0200
committerMartin Polden <mpolden@mpolden.no>2019-10-11 13:23:10 +0200
commitcc165c28e8a7ca17612927bcd4dd36b5bea862bb (patch)
treeaadcf666f1236892b4bc98532d0c3d37dbc02c7c
parentdfdbfe1162bd982468a8fa46961d5dcf42ab01a8 (diff)
Stop reading rotations property in config model
-rw-r--r--config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java2
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java14
-rw-r--r--config-model/src/main/java/com/yahoo/config/model/deploy/TestProperties.java4
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java1
-rw-r--r--config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java34
-rw-r--r--config-model/src/test/java/com/yahoo/config/model/deploy/DeployStateTest.java18
-rw-r--r--config-provisioning/src/main/java/com/yahoo/config/provision/Rotation.java1
7 files changed, 19 insertions, 55 deletions
diff --git a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
index 7ea96bb4bc6..d8c017b7775 100644
--- a/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
+++ b/config-model-api/src/main/java/com/yahoo/config/model/api/ModelContext.java
@@ -49,7 +49,7 @@ public interface ModelContext {
String athenzDnsSuffix();
boolean hostedVespa();
Zone zone();
- default Set<Rotation> rotations() { return Set.of(); }
+ default Set<Rotation> rotations() { return Set.of(); } // TODO(mpolden): Remove once 7.122 is the oldest config model
Set<ContainerEndpoint> endpoints();
boolean isBootstrap();
boolean isFirstTimeDeployment();
diff --git a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
index e8e12888768..0f43be96e73 100644
--- a/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
+++ b/config-model/src/main/java/com/yahoo/config/model/deploy/DeployState.java
@@ -71,7 +71,6 @@ public class DeployState implements ConfigDefinitionStore {
private final Optional<Model> previousModel;
private final ModelContext.Properties properties;
private final Version vespaVersion;
- private final Set<Rotation> rotations;
private final Set<ContainerEndpoint> endpoints;
private final Zone zone;
private final QueryProfiles queryProfiles;
@@ -105,7 +104,6 @@ public class DeployState implements ConfigDefinitionStore {
Optional<ApplicationPackage> permanentApplicationPackage,
Optional<ConfigDefinitionRepo> configDefinitionRepo,
java.util.Optional<Model> previousModel,
- Set<Rotation> rotations,
Set<ContainerEndpoint> endpoints,
Collection<MlModelImporter> modelImporters,
Zone zone,
@@ -125,7 +123,6 @@ public class DeployState implements ConfigDefinitionStore {
this.documentModel = searchDocumentModel.getDocumentModel();
this.permanentApplicationPackage = permanentApplicationPackage;
this.configDefinitionRepo = configDefinitionRepo;
- this.rotations = rotations;
this.endpoints = Set.copyOf(endpoints);
this.zone = zone;
this.queryProfiles = queryProfiles; // TODO: Remove this by seeing how pagetemplates are propagated
@@ -242,10 +239,6 @@ public class DeployState implements ConfigDefinitionStore {
return properties.hostedVespa();
}
- public Set<Rotation> getRotations() {
- return this.rotations; // todo: consider returning a copy or immutable view
- }
-
public Set<ContainerEndpoint> getEndpoints() {
return endpoints;
}
@@ -293,7 +286,6 @@ public class DeployState implements ConfigDefinitionStore {
private Version version = new Version(1, 0, 0);
private Optional<ConfigDefinitionRepo> configDefinitionRepo = Optional.empty();
private Optional<Model> previousModel = Optional.empty();
- private Set<Rotation> rotations = new HashSet<>();
private Set<ContainerEndpoint> endpoints = Set.of();
private Collection<MlModelImporter> modelImporters = Collections.emptyList();
private Zone zone = Zone.defaultZone();
@@ -346,11 +338,6 @@ public class DeployState implements ConfigDefinitionStore {
return this;
}
- public Builder rotations(Set<Rotation> rotations) {
- this.rotations = rotations;
- return this;
- }
-
public Builder endpoints(Set<ContainerEndpoint> endpoints) {
this.endpoints = endpoints;
return this;
@@ -396,7 +383,6 @@ public class DeployState implements ConfigDefinitionStore {
permanentApplicationPackage,
configDefinitionRepo,
previousModel,
- rotations,
endpoints,
modelImporters,
zone,
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 c304e7efa09..dc64bec964e 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
@@ -8,7 +8,6 @@ import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.api.TlsSecrets;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
-import com.yahoo.config.provision.Rotation;
import com.yahoo.config.provision.Zone;
import java.net.URI;
@@ -25,6 +24,7 @@ import java.util.Set;
* @author hakonhall
*/
public class TestProperties implements ModelContext.Properties {
+
private boolean multitenant = false;
private ApplicationId applicationId = ApplicationId.defaultId();
private List<ConfigServerSpec> configServerSpecs = Collections.emptyList();
@@ -33,7 +33,6 @@ public class TestProperties implements ModelContext.Properties {
private String athenzDnsSuffix = null;
private boolean hostedVespa = false;
private Zone zone;
- private Set<Rotation> rotations;
private Set<ContainerEndpoint> endpoints = Collections.emptySet();
private boolean isBootstrap = false;
private boolean isFirstTimeDeployment = false;
@@ -51,7 +50,6 @@ public class TestProperties implements ModelContext.Properties {
@Override public String athenzDnsSuffix() { return athenzDnsSuffix; }
@Override public boolean hostedVespa() { return hostedVespa; }
@Override public Zone zone() { return zone; }
- @Override public Set<Rotation> rotations() { return rotations; }
@Override public Set<ContainerEndpoint> endpoints() { return endpoints; }
@Override public boolean isBootstrap() { return isBootstrap; }
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java
index ca5c188ddb1..1dc0b838470 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/VespaModelFactory.java
@@ -140,7 +140,6 @@ public class VespaModelFactory implements ModelFactory {
.properties(modelContext.properties())
.vespaVersion(version())
.modelHostProvisioner(createHostProvisioner(modelContext))
- .rotations(modelContext.properties().rotations())
.endpoints(modelContext.properties().endpoints())
.modelImporters(modelImporters)
.zone(zone)
diff --git a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
index 1c0645aef2b..efc566f2dec 100644
--- a/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
+++ b/config-model/src/main/java/com/yahoo/vespa/model/container/xml/ContainerModelBuilder.java
@@ -24,7 +24,6 @@ import com.yahoo.config.provision.ClusterSpec;
import com.yahoo.config.provision.Environment;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeType;
-import com.yahoo.config.provision.Rotation;
import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.Zone;
import com.yahoo.search.rendering.RendererRegistry;
@@ -79,7 +78,6 @@ import org.w3c.dom.Node;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -223,14 +221,13 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
context.getDeployState().getProperties().athenzDnsSuffix(),
context.getDeployState().zone(),
deploymentSpec);
- addRotationProperties(cluster, context.getDeployState().zone(), context.getDeployState().getRotations(), context.getDeployState().getEndpoints(), deploymentSpec);
+ addRotationProperties(cluster, context.getDeployState().zone(), context.getDeployState().getEndpoints(), deploymentSpec);
});
}
- private void addRotationProperties(ApplicationContainerCluster cluster, Zone zone, Set<Rotation> rotations, Set<ContainerEndpoint> endpoints, DeploymentSpec spec) {
- Optional<String> globalServiceId = spec.instance(app.getApplicationId().instance()).flatMap(instance -> instance.globalServiceId());
+ private void addRotationProperties(ApplicationContainerCluster cluster, Zone zone, Set<ContainerEndpoint> endpoints, DeploymentSpec spec) {
cluster.getContainers().forEach(container -> {
- setRotations(container, rotations, endpoints, globalServiceId, cluster.getName());
+ setRotations(container, endpoints, cluster.getName());
container.setProp("activeRotation", Boolean.toString(zoneHasActiveRotation(zone, spec)));
});
}
@@ -243,26 +240,11 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> {
declaredZone.active());
}
- private void setRotations(Container container,
- Set<Rotation> rotations,
- Set<ContainerEndpoint> endpoints,
- Optional<String> globalServiceId,
- String containerClusterName) {
- final Set<String> rotationsProperty = new HashSet<>();
-
- // Add the legacy rotations to the list of available rotations. Using the same test
- // as was used before to mirror the old business logic for global-service-id.
- if ( ! rotations.isEmpty() && globalServiceId.isPresent()) {
- if (containerClusterName.equals(globalServiceId.get())) {
- rotations.stream().map(Rotation::getId).forEach(rotationsProperty::add);
- }
- }
-
- // For ContainerEndpoints this is more straight-forward, just add all that are present
- endpoints.stream()
- .filter(endpoint -> endpoint.clusterId().equals(containerClusterName))
- .flatMap(endpoint -> endpoint.names().stream())
- .forEach(rotationsProperty::add);
+ private void setRotations(Container container, Set<ContainerEndpoint> endpoints, String containerClusterName) {
+ var rotationsProperty = endpoints.stream()
+ .filter(endpoint -> endpoint.clusterId().equals(containerClusterName))
+ .flatMap(endpoint -> endpoint.names().stream())
+ .collect(Collectors.toUnmodifiableSet());
// Build the comma delimited list of endpoints this container should be known as.
// Confusingly called 'rotations' for legacy reasons.
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 383446228cc..d243a2dacf6 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
@@ -3,13 +3,13 @@ package com.yahoo.config.model.deploy;
import com.yahoo.config.application.api.ApplicationPackage;
import com.yahoo.config.model.api.ConfigDefinitionRepo;
+import com.yahoo.config.model.api.ContainerEndpoint;
import com.yahoo.config.model.api.HostProvisioner;
import com.yahoo.config.model.api.ModelContext;
import com.yahoo.config.model.application.provider.FilesApplicationPackage;
import com.yahoo.config.model.provision.InMemoryProvisioner;
import com.yahoo.config.model.test.MockApplicationPackage;
import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.Rotation;
import com.yahoo.vespa.config.ConfigDefinition;
import com.yahoo.vespa.config.ConfigDefinitionKey;
import com.yahoo.vespa.model.VespaModel;
@@ -18,16 +18,17 @@ import org.xml.sax.SAXException;
import java.io.File;
import java.io.IOException;
-import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
-import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
/**
* @author Ulf Lilleengen
@@ -108,13 +109,10 @@ public class DeployStateTest {
}
@Test
- public void testRotations() {
- Set<Rotation> rotations = new HashSet<>();
- assertThat(new DeployState.Builder().rotations(rotations).build().getRotations().size(), is(0));
- for (String name : new String[]{"rotation-001.vespa.a02.yahoodns.net", "rotation-002.vespa.a02.yahoodns.net"}) {
- rotations.add(new Rotation(name));
- }
- assertThat(new DeployState.Builder().rotations(rotations).build().getRotations(), equalTo(rotations));
+ public void testContainerEndpoints() {
+ assertTrue(new DeployState.Builder().endpoints(Set.of()).build().getEndpoints().isEmpty());
+ var endpoints = Set.of(new ContainerEndpoint("c1", List.of("c1.example.com", "c1-alias.example.com")));
+ assertEquals(endpoints, new DeployState.Builder().endpoints(endpoints).build().getEndpoints());
}
private DeployState createDeployState(ApplicationPackage app, Map<ConfigDefinitionKey, com.yahoo.vespa.config.buildergen.ConfigDefinition> defs) {
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/Rotation.java b/config-provisioning/src/main/java/com/yahoo/config/provision/Rotation.java
index 75b7d790eba..d1cf86c6d16 100644
--- a/config-provisioning/src/main/java/com/yahoo/config/provision/Rotation.java
+++ b/config-provisioning/src/main/java/com/yahoo/config/provision/Rotation.java
@@ -6,6 +6,7 @@ import java.util.Objects;
/**
* A rotation (virtual endpoint).
*/
+// TODO(mpolden): Remove once 7.122 is the oldest config model
public class Rotation {
private final String id;