diff options
author | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-07-11 14:08:16 +0200 |
---|---|---|
committer | Øyvind Grønnesby <oyving@verizonmedia.com> | 2019-07-11 14:08:16 +0200 |
commit | 2f95dbec5a6d82f2eda41dbeea594eb41f135223 (patch) | |
tree | d5879d8fbe9ff2c99c811f8da1c29e300a8b39a2 /controller-server | |
parent | 1c79079945c56fa91de8427fbc8f2170eec9ed8c (diff) |
Do not read legacy rotation/endpoint fields
Diffstat (limited to 'controller-server')
2 files changed, 2 insertions, 58 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java index 0c045eb7253..135586972b1 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializer.java @@ -555,27 +555,6 @@ public class ApplicationSerializer { private List<AssignedRotation> assignedRotationsFromSlime(DeploymentSpec deploymentSpec, Inspector root) { final var assignedRotations = new LinkedHashMap<EndpointId, AssignedRotation>(); - // Add the legacy rotation field to the set - this needs to be first - // TODO: Remove when we retire the rotations field - final var legacyRotation = legacyRotationFromSlime(root.field(deprecatedRotationField)); - if (legacyRotation.isPresent() && deploymentSpec.globalServiceId().isPresent()) { - final var clusterId = new ClusterSpec.Id(deploymentSpec.globalServiceId().get()); - final var regions = deploymentSpec.zones().stream().flatMap(zone -> zone.region().stream()).collect(Collectors.toSet()); - assignedRotations.putIfAbsent(EndpointId.default_(), new AssignedRotation(clusterId, EndpointId.default_(), legacyRotation.get(), regions)); - } - - // Now add the same entries from "stupid" list of rotations - // TODO: Remove when we retire the rotations field - final var rotations = rotationListFromSlime(root.field(rotationsField)); - for (var rotation : rotations) { - final var regions = deploymentSpec.zones().stream().flatMap(zone -> zone.region().stream()).collect(Collectors.toSet()); - if (deploymentSpec.globalServiceId().isPresent()) { - final var clusterId = new ClusterSpec.Id(deploymentSpec.globalServiceId().get()); - assignedRotations.putIfAbsent(EndpointId.default_(), new AssignedRotation(clusterId, EndpointId.default_(), rotation, regions)); - } - } - - // Last - add the actual entries we want. Do _not_ remove this during clean-up root.field(assignedRotationsField).traverse((ArrayTraverser) (idx, inspector) -> { final var clusterId = new ClusterSpec.Id(inspector.field(assignedRotationClusterField).asString()); final var endpointId = EndpointId.of(inspector.field(assignedRotationEndpointField).asString()); diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java index 7b39b0d53a4..aca4f750649 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/persistence/ApplicationSerializerTest.java @@ -253,9 +253,8 @@ public class ApplicationSerializerTest { // ok if no error } - /** TODO: Test can be removed after June 2019 - once legacy field for single rotation is retired */ @Test - public void testParsingLegacyRotationElement() throws IOException { + public void testParsingAssignedRotations() throws IOException { // Use the 'complete-application.json' as a baseline final var applicationJson = Files.readAllBytes(testData.resolve("complete-application.json")); final var slime = SlimeUtils.jsonToSlime(applicationJson); @@ -267,12 +266,6 @@ public class ApplicationSerializerTest { // Add the necessary fields to the Slime representation of the application final var cursor = slime.get(); - cursor.setString("rotation", "single-rotation"); - - final var rotations = cursor.setArray("endpoints"); - rotations.addString("multiple-rotation-1"); - rotations.addString("multiple-rotation-2"); - final var assignedRotations = cursor.setArray("assignedRotations"); final var assignedRotation = assignedRotations.addObject(); assignedRotation.setString("clusterId", "foobar"); @@ -282,51 +275,23 @@ public class ApplicationSerializerTest { // Parse and test the output from parsing contains both legacy rotation and multiple rotations final var application = applicationSerializer.fromSlime(slime); - // Since only one AssignedEndpoint can be "default", we make sure that we are ignoring the - // multiple-rotation entries as the globalServiceId will override them assertEquals( List.of( - new RotationId("single-rotation"), new RotationId("assigned-rotation") ), application.rotations() ); assertEquals( - Optional.of(new RotationId("single-rotation")), application.legacyRotation() + Optional.of(new RotationId("assigned-rotation")), application.legacyRotation() ); - // The same goes here for AssignedRotations with "default" EndpointId as in the .rotations() test above. - // Note that we are only using Set.of() on "assigned-rotation" because in this test we do not have access - // to a deployment.xml that describes the zones a rotation should map to. assertEquals( List.of( - new AssignedRotation(new ClusterSpec.Id("foo"), EndpointId.of("default"), new RotationId("single-rotation"), regions), new AssignedRotation(new ClusterSpec.Id("foobar"), EndpointId.of("nice-endpoint"), new RotationId("assigned-rotation"), Set.of()) ), application.assignedRotations() ); } - @Test - public void testParsingOnlyLegacyRotationElement() throws IOException { - // Use the 'complete-application.json' as a baseline - final var applicationJson = Files.readAllBytes(testData.resolve("complete-application.json")); - final var slime = SlimeUtils.jsonToSlime(applicationJson); - - // Add the necessary fields to the Slime representation of the application - final var cursor = slime.get(); - - cursor.setString("rotation", "single-rotation"); - - // Parse and test the output from parsing contains both legacy rotation and multiple rotations - final var application = applicationSerializer.fromSlime(slime); - - assertEquals( - List.of( - new RotationId("single-rotation") - ), - application.rotations() - ); - } } |