aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2021-02-04 10:26:44 +0100
committerMartin Polden <mpolden@mpolden.no>2021-02-04 10:26:44 +0100
commit2f6874740119b06a98782dd774844b7299a76eb4 (patch)
tree578f9f78e33e73182c400d0a070c367930787888 /controller-server
parentb434914ac7aafd49adad156dd070af941a813985 (diff)
Remove RotationStatusUpdater
Diffstat (limited to 'controller-server')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java1
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java106
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java92
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java8
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json2
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation.json4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance.json4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json4
-rw-r--r--controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json3
9 files changed, 10 insertions, 214 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
index 081c6afa2b8..e684af38b09 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/ControllerMaintenance.java
@@ -56,7 +56,6 @@ public class ControllerMaintenance extends AbstractComponent {
maintainers.add(new CostReportMaintainer(controller, intervals.costReportMaintainer, controller.serviceRegistry().costReportConsumer()));
maintainers.add(new ResourceMeterMaintainer(controller, intervals.resourceMeterMaintainer, metric, controller.serviceRegistry().meteringService()));
maintainers.add(new CloudEventReporter(controller, intervals.cloudEventReporter, metric));
- maintainers.add(new RotationStatusUpdater(controller, intervals.defaultInterval));
maintainers.add(new ResourceTagMaintainer(controller, intervals.resourceTagMaintainer, controller.serviceRegistry().resourceTagger()));
maintainers.add(new SystemRoutingPolicyMaintainer(controller, intervals.systemRoutingPolicyMaintainer));
maintainers.add(new ApplicationMetaDataGarbageCollector(controller, intervals.applicationMetaDataGarbageCollector));
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java
deleted file mode 100644
index 935bcbec597..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdater.java
+++ /dev/null
@@ -1,106 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.maintenance;
-
-import com.yahoo.vespa.hosted.controller.ApplicationController;
-import com.yahoo.vespa.hosted.controller.Controller;
-import com.yahoo.vespa.hosted.controller.Instance;
-import com.yahoo.vespa.hosted.controller.api.integration.routing.GlobalRoutingService;
-import com.yahoo.vespa.hosted.controller.application.ApplicationList;
-import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId;
-import com.yahoo.vespa.hosted.controller.rotation.RotationId;
-import com.yahoo.vespa.hosted.controller.rotation.RotationState;
-import com.yahoo.vespa.hosted.controller.rotation.RotationStatus;
-import com.yahoo.yolean.Exceptions;
-
-import java.time.Duration;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.ForkJoinPool;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.logging.Level;
-import java.util.stream.Collectors;
-
-/**
- * Periodically updates the status of assigned global rotations.
- *
- * @author mpolden
- */
-public class RotationStatusUpdater extends ControllerMaintainer {
-
- private static final int applicationsToUpdateInParallel = 10;
-
- private final GlobalRoutingService service;
- private final ApplicationController applications;
-
- public RotationStatusUpdater(Controller controller, Duration interval) {
- super(controller, interval);
- this.service = controller.serviceRegistry().globalRoutingService();
- this.applications = controller.applications();
- }
-
- @Override
- protected boolean maintain() {
- var failures = new AtomicInteger(0);
- var attempts = new AtomicInteger(0);
- var lastException = new AtomicReference<Exception>(null);
- var instancesWithRotations = ApplicationList.from(applications.readable()).hasRotation().asList().stream()
- .flatMap(application -> application.instances().values().stream())
- .filter(instance -> ! instance.rotations().isEmpty());
-
- // Run parallel stream inside a custom ForkJoinPool so that we can control the number of threads used
- var pool = new ForkJoinPool(applicationsToUpdateInParallel);
-
- pool.submit(() -> {
- instancesWithRotations.parallel().forEach(instance -> {
- attempts.incrementAndGet();
- try {
- RotationStatus status = getStatus(instance);
- applications.lockApplicationIfPresent(TenantAndApplicationId.from(instance.id()), app ->
- applications.store(app.with(instance.name(), locked -> locked.with(status))));
- } catch (Exception e) {
- failures.incrementAndGet();
- lastException.set(e);
- }
- });
- });
- pool.shutdown();
- try {
- pool.awaitTermination(30, TimeUnit.SECONDS);
- if (lastException.get() != null) {
- log.log(Level.WARNING, String.format("Failed to get global routing status of %d/%d applications. Retrying in %s. Last error: %s",
- failures.get(),
- attempts.get(),
- interval(),
- Exceptions.toMessageString(lastException.get())));
- }
- } catch (InterruptedException e) {
- throw new RuntimeException(e);
- }
- return lastException.get() == null;
- }
-
- private RotationStatus getStatus(Instance instance) {
- var statusMap = new LinkedHashMap<RotationId, RotationStatus.Targets>();
- for (var assignedRotation : instance.rotations()) {
- var rotation = controller().routing().rotations().getRotation(assignedRotation.rotationId());
- if (rotation.isEmpty()) continue;
- var targets = service.getHealthStatus(rotation.get().name()).entrySet().stream()
- .collect(Collectors.toMap(Map.Entry::getKey, (kv) -> from(kv.getValue())));
- var lastUpdated = controller().clock().instant();
- statusMap.put(assignedRotation.rotationId(), new RotationStatus.Targets(targets, lastUpdated));
- }
- return RotationStatus.from(statusMap);
- }
-
- private static RotationState from(com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus status) {
- switch (status) {
- case IN: return RotationState.in;
- case OUT: return RotationState.out;
- case UNKNOWN: return RotationState.unknown;
- default: throw new IllegalArgumentException("Unknown API value for rotation status: " + status);
- }
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java
deleted file mode 100644
index 87c9a4996b9..00000000000
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/maintenance/RotationStatusUpdaterTest.java
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.maintenance;
-
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.zone.ZoneId;
-import com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus;
-import com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder;
-import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
-import com.yahoo.vespa.hosted.controller.rotation.RotationState;
-import org.junit.Test;
-
-import java.time.Duration;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author mpolden
- */
-public class RotationStatusUpdaterTest {
-
- @Test
- public void updates_rotation_status() {
- var tester = new DeploymentTester();
- var globalRotationService = tester.controllerTester().serviceRegistry().globalRoutingServiceMock();
- var updater = new RotationStatusUpdater(tester.controller(), Duration.ofDays(1));
-
- var context = tester.newDeploymentContext(ApplicationId.from("tenant1", "app1", "default"));
- var zone1 = ZoneId.from("prod", "us-west-1");
- var zone2 = ZoneId.from("prod", "us-east-3");
- var zone3 = ZoneId.from("prod", "eu-west-1");
-
- // Deploy application with global rotation
- var applicationPackage = new ApplicationPackageBuilder()
- .globalServiceId("foo")
- .region(zone1.region().value())
- .region(zone2.region().value())
- .build();
- context.submit(applicationPackage)
- .deploy();
-
- // No status gathered yet
- var rotation1 = context.instance().rotations().get(0).rotationId();
- assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation1, context.deployment(zone1)));
- assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation1, context.deployment(zone2)));
-
- // First rotation: One zone out, one in
- var rotationName1 = "rotation-fqdn-01";
- globalRotationService.setStatus(rotationName1, zone1, RotationStatus.IN)
- .setStatus(rotationName1, zone2, RotationStatus.OUT);
- updater.maintain();
- assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone1)));
- assertEquals(RotationState.out, context.instance().rotationStatus().of(rotation1, context.deployment(zone2)));
-
- // First rotation: All zones in
- globalRotationService.setStatus(rotationName1, zone2, RotationStatus.IN);
- updater.maintain();
- assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone1)));
- assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation1, context.deployment(zone2)));
-
- // Another rotation is assigned
- applicationPackage = new ApplicationPackageBuilder()
- .region(zone1.region().value())
- .region(zone2.region().value())
- .region(zone3.region().value())
- .endpoint("default", "foo", "us-east-3", "us-west-1")
- .endpoint("eu", "default", "eu-west-1")
- .build();
- context.submit(applicationPackage)
- .deploy();
- assertEquals(2, context.instance().rotations().size());
-
- // Second rotation: No status gathered yet
- var rotation2 = context.instance().rotations().get(1).rotationId();
- updater.maintain();
- assertEquals(RotationState.unknown, context.instance().rotationStatus().of(rotation2, context.deployment(zone3)));
-
- // Status of third zone is retrieved via second rotation
- var rotationName2 = "rotation-fqdn-02";
- globalRotationService.setStatus(rotationName2, zone3, RotationStatus.IN);
- updater.maintain();
- assertEquals(RotationState.in, context.instance().rotationStatus().of(rotation2, context.deployment(zone3)));
-
- // Each rotation only has status for their configured zones
- assertEquals("Rotation " + rotation1 + " does not know about " + context.deployment(zone3), RotationState.unknown,
- context.instance().rotationStatus().of(rotation1, context.deployment(zone3)));
- assertEquals("Rotation " + rotation2 + " does not know about " + context.deployment(zone1), RotationState.unknown,
- context.instance().rotationStatus().of(rotation2, context.deployment(zone1)));
- assertEquals("Rotation " + rotation2 + " does not know about " + context.deployment(zone2), RotationState.unknown,
- context.instance().rotationStatus().of(rotation2, context.deployment(zone2)));
- }
-
-}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
index 6626134b69a..9c3d71710ec 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiTest.java
@@ -59,7 +59,6 @@ import com.yahoo.vespa.hosted.controller.deployment.DeploymentTester;
import com.yahoo.vespa.hosted.controller.deployment.DeploymentTrigger;
import com.yahoo.vespa.hosted.controller.integration.ConfigServerMock;
import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock;
-import com.yahoo.vespa.hosted.controller.maintenance.RotationStatusUpdater;
import com.yahoo.vespa.hosted.controller.metric.ApplicationMetrics;
import com.yahoo.vespa.hosted.controller.restapi.ContainerTester;
import com.yahoo.vespa.hosted.controller.restapi.ControllerContainerTest;
@@ -75,7 +74,6 @@ import org.junit.Test;
import java.io.File;
import java.net.URI;
-import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
@@ -954,7 +952,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/us-west-1/global-rotation", GET)
.properties(Map.of("endpointId", "default"))
.userIdentity(USER_ID),
- "{\"bcpStatus\":{\"rotationStatus\":\"IN\"}}",
+ "{\"bcpStatus\":{\"rotationStatus\":\"UNKNOWN\"}}",
200);
// GET global rotation status for us-west-1 in eu endpoint
@@ -968,7 +966,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
tester.assertResponse(request("/application/v4/tenant/tenant1/application/application1/instance/instance1/environment/prod/region/eu-west-1/global-rotation", GET)
.properties(Map.of("endpointId", "eu"))
.userIdentity(USER_ID),
- "{\"bcpStatus\":{\"rotationStatus\":\"IN\"}}",
+ "{\"bcpStatus\":{\"rotationStatus\":\"UNKNOWN\"}}",
200);
}
@@ -1655,7 +1653,7 @@ public class ApplicationApiTest extends ControllerContainerTest {
private void setZoneInRotation(String rotationName, ZoneId zone) {
tester.serviceRegistry().globalRoutingServiceMock().setStatus(rotationName, zone, com.yahoo.vespa.hosted.controller.api.integration.routing.RotationStatus.IN);
- new RotationStatusUpdater(tester.controller(), Duration.ofDays(1)).run();
+ //new RotationStatusUpdater(tester.controller(), Duration.ofDays(1)).run();
}
private void updateContactInformation() {
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json
index a7755278a39..946593fca00 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/deployment.json
@@ -35,7 +35,7 @@
"endpointId": "default",
"rotationId": "rotation-id-1",
"clusterId": "foo",
- "status": "IN",
+ "status": "UNKNOWN",
"lastUpdated": "(ignore)"
}
],
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation.json
index 530e21c6c7a..ea8c63cffb6 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/global-rotation.json
@@ -1,5 +1,5 @@
{
"bcpStatus": {
- "rotationStatus": "IN"
+ "rotationStatus": "UNKNOWN"
}
-} \ No newline at end of file
+}
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance.json
index 1b2c0b4e237..745d0ad162a 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/instance.json
@@ -62,14 +62,14 @@
},
{
"bcpStatus": {
- "rotationStatus": "IN"
+ "rotationStatus": "UNKNOWN"
},
"endpointStatus": [
{
"endpointId": "default",
"rotationId": "rotation-id-1",
"clusterId": "foo",
- "status": "IN",
+ "status": "UNKNOWN",
"lastUpdated": "(ignore)"
}
],
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json
index 4d387f626a1..4251ba1ad95 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/application/responses/prod-us-central-1.json
@@ -1,6 +1,6 @@
{
"bcpStatus": {
- "rotationStatus": "IN"
+ "rotationStatus": "UNKNOWN"
},
"tenant": "tenant1",
"application": "application1",
@@ -38,7 +38,7 @@
"endpointId": "default",
"rotationId": "rotation-id-1",
"clusterId": "foo",
- "status": "IN",
+ "status": "UNKNOWN",
"lastUpdated": "(ignore)"
}
],
diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
index 6f67b0d8aa8..14fd7abd96c 100644
--- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
+++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/controller/responses/maintenance.json
@@ -64,9 +64,6 @@
"name": "ResourceTagMaintainer"
},
{
- "name": "RotationStatusUpdater"
- },
- {
"name": "SystemRoutingPolicyMaintainer"
},
{