diff options
author | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-31 10:07:38 +0100 |
---|---|---|
committer | Jon Marius Venstad <jvenstad@yahoo-inc.com> | 2018-10-31 10:07:38 +0100 |
commit | 9cb36563c075a80c39eb73d82628af2ad2339cde (patch) | |
tree | 209daa4b7b32f762c3a0f87671b64da8241451cc /controller-server | |
parent | 6cf7e45914d4f02cd3e41ecd26ac0201098ce788 (diff) |
Restrict endpoint and cluster list fetching to tested and production zones
Diffstat (limited to 'controller-server')
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index 5fd197eb785..da1c2ec753b 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -44,10 +44,12 @@ import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Optional; +import java.util.Set; import java.util.function.Supplier; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import java.util.stream.Stream; import static com.yahoo.log.LogLevel.DEBUG; import static com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException.ErrorCode.ACTIVATION_CONFLICT; @@ -321,8 +323,10 @@ public class InternalStepRunner implements StepRunner { return Optional.of(aborted); } + Set<ZoneId> zones = testedZoneAndProductionZones(id); + logger.log("Attempting to find endpoints ..."); - Map<ZoneId, List<URI>> endpoints = deploymentEndpoints(id.application()); + Map<ZoneId, List<URI>> endpoints = deploymentEndpoints(id.application(), zones); logger.log("Found endpoints:\n" + endpoints.entrySet().stream() .map(zoneEndpoints -> "- " + zoneEndpoints.getKey() + ":\n" + @@ -340,7 +344,7 @@ public class InternalStepRunner implements StepRunner { return Optional.empty(); } - Map<ZoneId, List<String>> clusters = listClusters(id.application()); + Map<ZoneId, List<String>> clusters = listClusters(id.application(), zones); Optional<URI> testerEndpoint = controller.jobController().testerEndpoint(id); if (testerEndpoint.isPresent() && controller.jobController().cloud().ready(testerEndpoint.get())) { @@ -464,21 +468,28 @@ public class InternalStepRunner implements StepRunner { } } + /** Returns a stream containing the zone of the deployment tested in the given run, and all production zones for the application. */ + private Set<ZoneId> testedZoneAndProductionZones(RunId id) { + return Stream.concat(Stream.of(id.type().zone(controller.system())), + application(id.application()).productionDeployments().keySet().stream()) + .collect(Collectors.toSet()); + } + /** Returns all endpoints for all current deployments of the given real application. */ - private Map<ZoneId, List<URI>> deploymentEndpoints(ApplicationId id) { + private Map<ZoneId, List<URI>> deploymentEndpoints(ApplicationId id, Iterable<ZoneId> zones) { ImmutableMap.Builder<ZoneId, List<URI>> deployments = ImmutableMap.builder(); - application(id).deployments().keySet() - .forEach(zone -> controller.applications().getDeploymentEndpoints(new DeploymentId(id, zone)) - .filter(endpoints -> ! endpoints.isEmpty()) - .ifPresent(endpoints -> deployments.put(zone, endpoints))); + for (ZoneId zone : zones) + controller.applications().getDeploymentEndpoints(new DeploymentId(id, zone)) + .filter(endpoints -> ! endpoints.isEmpty()) + .ifPresent(endpoints -> deployments.put(zone, endpoints)); return deployments.build(); } /** Returns all content clusters in all current deployments of the given real application. */ - private Map<ZoneId, List<String>> listClusters(ApplicationId id) { + private Map<ZoneId, List<String>> listClusters(ApplicationId id, Iterable<ZoneId> zones) { ImmutableMap.Builder<ZoneId, List<String>> clusters = ImmutableMap.builder(); - application(id).deployments().keySet() - .forEach(zone -> clusters.put(zone, ImmutableList.copyOf(controller.configServer().getContentClusters(new DeploymentId(id, zone))))); + for (ZoneId zone : zones) + clusters.put(zone, ImmutableList.copyOf(controller.configServer().getContentClusters(new DeploymentId(id, zone)))); return clusters.build(); } |