diff options
author | Martin Polden <mpolden@mpolden.no> | 2023-07-26 16:23:50 +0200 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2023-07-27 13:17:42 +0200 |
commit | 60f174c4f1a19a94ba896c4bad7a6df91198c78e (patch) | |
tree | c921accbcf27cf83c7ff77f4e77e91ca22c84c80 /config-model | |
parent | abc51d778d3f370e04cf79d649db59cc3e596449 (diff) |
Remove active attribute
Diffstat (limited to 'config-model')
5 files changed, 30 insertions, 52 deletions
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 1036a615bb5..31f8eba48bf 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 @@ -10,7 +10,6 @@ import com.yahoo.config.application.Xml; import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.application.api.DeployLogger; -import com.yahoo.config.application.api.DeploymentInstanceSpec; import com.yahoo.config.application.api.DeploymentSpec; import com.yahoo.config.model.ConfigModelContext; import com.yahoo.config.model.api.ApplicationClusterEndpoint; @@ -360,24 +359,16 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { context.getDeployState().getProperties().athenzDnsSuffix(), context.getDeployState().zone(), deploymentSpec); - addRotationProperties(cluster, context.getDeployState().zone(), context.getDeployState().getEndpoints(), deploymentSpec); + addRotationProperties(cluster, context.getDeployState().getEndpoints()); } - private void addRotationProperties(ApplicationContainerCluster cluster, Zone zone, Set<ContainerEndpoint> endpoints, DeploymentSpec spec) { + private void addRotationProperties(ApplicationContainerCluster cluster, Set<ContainerEndpoint> endpoints) { cluster.getContainers().forEach(container -> { setRotations(container, endpoints, cluster.getName()); - container.setProp("activeRotation", Boolean.toString(zoneHasActiveRotation(zone, spec))); + container.setProp("activeRotation", "true"); // TODO(mpolden): This is unused and should be removed }); } - private boolean zoneHasActiveRotation(Zone zone, DeploymentSpec spec) { - Optional<DeploymentInstanceSpec> instance = spec.instance(app.getApplicationId().instance()); - if (instance.isEmpty()) return false; - return instance.get().zones().stream() - .anyMatch(declaredZone -> declaredZone.concerns(zone.environment(), Optional.of(zone.region())) && - declaredZone.active()); - } - private void setRotations(Container container, Set<ContainerEndpoint> endpoints, String containerClusterName) { var rotationsProperty = endpoints.stream() .filter(endpoint -> endpoint.clusterId().equals(containerClusterName)) @@ -594,7 +585,7 @@ public class ContainerModelBuilder extends ConfigModelBuilder<ContainerModel> { private void addDefaultConnectorHostedFilterBinding(ApplicationContainerCluster cluster) { cluster.getHttp().getAccessControl() - .ifPresent(accessControl -> accessControl.configureDefaultHostedConnector(cluster.getHttp())); ; + .ifPresent(accessControl -> accessControl.configureDefaultHostedConnector(cluster.getHttp())); } private void addCloudMtlsConnector(DeployState state, ApplicationContainerCluster cluster) { diff --git a/config-model/src/test/cfg/application/app_complicated_deployment_spec/deployment.xml b/config-model/src/test/cfg/application/app_complicated_deployment_spec/deployment.xml index 3d3bfd35845..e30c02cdd84 100644 --- a/config-model/src/test/cfg/application/app_complicated_deployment_spec/deployment.xml +++ b/config-model/src/test/cfg/application/app_complicated_deployment_spec/deployment.xml @@ -5,24 +5,24 @@ <instance id='instance' athenz-service='in-service'> <prod> <parallel> - <region active='true'>us-west-1</region> + <region>us-west-1</region> <steps> - <region active='true'>us-east-3</region> + <region>us-east-3</region> <delay hours='2' /> - <region active='true'>eu-west-1</region> + <region>eu-west-1</region> <delay hours='2' /> </steps> <steps> <delay hours='3' /> - <region active='true'>aws-us-east-1a</region> + <region>aws-us-east-1a</region> <parallel> - <region active='true' athenz-service='no-service'>ap-northeast-1</region> - <region active='true'>ap-southeast-2</region> + <region athenz-service='no-service'>ap-northeast-1</region> + <region>ap-southeast-2</region> </parallel> </steps> <delay hours='3' minutes='30' /> </parallel> - <region active='true'>us-north-7</region> + <region>us-north-7</region> </prod> </instance> <instance id='other'> @@ -30,7 +30,7 @@ <block-change days='sat' hours='10' time-zone='CET' /> <test /> <prod> - <region active='true'>eu-central-2</region> + <region>eu-central-2</region> </prod> <notifications when='failing'> <email role='author' /> diff --git a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java index 92efac74530..9ce853ad0f2 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/application/validation/DeploymentSpecValidatorTest.java @@ -24,7 +24,7 @@ public class DeploymentSpecValidatorTest { "<deployment version='1.0'>" + " <test />" + " <prod>" + - " <region active='true'>us-east</region>" + + " <region>us-east</region>" + " </prod>" + " <endpoints>" + " <endpoint container-id='non-existing'/>" + diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java index 78269d00cf3..08877b3d3a9 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/IdentityBuilderTest.java @@ -24,7 +24,7 @@ public class IdentityBuilderTest extends ContainerModelBuilderTestBase { String deploymentXml = "<deployment version='1.0' athenz-domain='domain' athenz-service='service'>\n" + " <test/>\n" + " <prod>\n" + - " <region active='true'>default</region>\n" + + " <region>default</region>\n" + " </prod>\n" + "</deployment>\n"; diff --git a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java index 58b9462978f..2bf50103b10 100644 --- a/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java +++ b/config-model/src/test/java/com/yahoo/vespa/model/container/xml/RoutingBuilderTest.java @@ -10,14 +10,12 @@ import com.yahoo.config.model.test.MockRoot; import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.RegionName; import com.yahoo.config.provision.Zone; -import com.yahoo.vespa.model.container.ApplicationContainerCluster; import com.yahoo.vespa.model.container.ApplicationContainer; +import com.yahoo.vespa.model.container.ApplicationContainerCluster; import org.junit.jupiter.api.Test; import org.w3c.dom.Element; -import org.xml.sax.SAXException; -import java.io.IOException; -import java.util.Arrays; +import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,43 +25,32 @@ import static org.junit.jupiter.api.Assertions.assertEquals; public class RoutingBuilderTest extends ContainerModelBuilderTestBase { @Test - void setsRotationActiveAccordingToDeploymentSpec() throws IOException, SAXException { + void setsRotationActive() { Element clusterElem = DomBuilderTest.parse( "<container id='default' version='1.0'><search /></container>"); - String deploymentSpec = "<deployment>\n" + - " <prod> \n" + - " <region active='true'>us-north-1</region>\n" + - " <parallel>\n" + - " <region active='false'>us-north-2</region>\n" + - " <region active='true'>us-north-3</region>\n" + - " </parallel>\n" + - " <region active='false'>us-north-4</region>\n" + - " </prod>\n" + - "</deployment>"; + String deploymentSpec = """ + <deployment> + <prod> + <region>us-north-1</region> + <parallel> + <region>us-north-2</region> + <region>us-north-3</region> + </parallel> + <region>us-north-4</region> + </prod> + </deployment>"""; ApplicationPackage applicationPackage = new MockApplicationPackage.Builder() .withDeploymentSpec(deploymentSpec) .build(); - //root = new MockRoot("root", applicationPackage); - for (String region : Arrays.asList("us-north-1", "us-north-3")) { - ApplicationContainer container = getContainer(applicationPackage, region, clusterElem); + for (String region : List.of("us-north-1", "us-north-2", "us-north-3", "us-north-4")) { + ApplicationContainer container = getContainer(applicationPackage, region, clusterElem); assertEquals("true", container.getServicePropertyString("activeRotation"), "Region " + region + " is active"); } - for (String region : Arrays.asList("us-north-2", "us-north-4")) { - ApplicationContainer container = getContainer(applicationPackage, region, clusterElem); - - assertEquals("false", - container.getServicePropertyString("activeRotation"), - "Region " + region + " is inactive"); - } - ApplicationContainer container = getContainer(applicationPackage, "unknown", clusterElem); - assertEquals("false", - container.getServicePropertyString("activeRotation"), - "Unknown region is inactive"); } |