diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2019-10-18 13:19:59 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2019-10-18 13:19:59 +0200 |
commit | 49a63c3580918d1d7f7081290805cbd69141b00d (patch) | |
tree | 1d1bc2c9c280f9d771b9ec3c753ae684328cbc6c /controller-server | |
parent | 74653a7dc74420f12d6a87b5ff54977450697b20 (diff) |
Use default production deployments for developer test config
Diffstat (limited to 'controller-server')
4 files changed, 36 insertions, 23 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java index 703fc71dc31..d1fedd9c619 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java @@ -216,10 +216,10 @@ public class ApplicationController { public ApplicationStore applicationStore() { return applicationStore; } /** Returns all content clusters in all current deployments of the given application. */ - public Map<ZoneId, List<String>> contentClustersByZone(ApplicationId id, Iterable<ZoneId> zones) { + public Map<ZoneId, List<String>> contentClustersByZone(Collection<DeploymentId> ids) { ImmutableMap.Builder<ZoneId, List<String>> clusters = ImmutableMap.builder(); - for (ZoneId zone : zones) - clusters.put(zone, ImmutableList.copyOf(configServer.getContentClusters(new DeploymentId(id, zone)))); + for (DeploymentId id : ids) + clusters.put(id.zoneId(), ImmutableList.copyOf(configServer.getContentClusters(id))); return clusters.build(); } @@ -715,12 +715,13 @@ public class ApplicationController { } /** Returns all zone-specific cluster endpoints for the given application, in the given zones. */ - public Map<ZoneId, Map<ClusterSpec.Id, URI>> clusterEndpoints(ApplicationId id, Collection<ZoneId> zones) { + public Map<ZoneId, Map<ClusterSpec.Id, URI>> clusterEndpoints(Collection<DeploymentId> ids) { Map<ZoneId, Map<ClusterSpec.Id, URI>> deployments = new TreeMap<>(Comparator.comparing(ZoneId::value)); - for (ZoneId zone : zones) { - var endpoints = clusterEndpoints(new DeploymentId(id, zone)); - if ( ! endpoints.isEmpty()) - deployments.put(zone, endpoints); + for (DeploymentId id : ids) { + var endpoints = clusterEndpoints(id); + if ( ! endpoints.isEmpty()) { + deployments.put(id.zoneId(), endpoints); + } } return Collections.unmodifiableMap(deployments); } 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 7c656da3a67..33a16fc29d0 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 @@ -52,6 +52,7 @@ import java.security.cert.X509Certificate; import java.time.Duration; import java.util.ArrayList; import java.util.Date; +import java.util.HashSet; import java.util.List; import java.util.Locale; import java.util.Map; @@ -343,7 +344,7 @@ public class InternalStepRunner implements StepRunner { /** Returns true iff all containers in the deployment give 100 consecutive 200 OK responses on /status.html. */ private boolean containersAreUp(ApplicationId id, ZoneId zoneId, DualLogger logger) { - var endpoints = controller.applications().clusterEndpoints(id, Set.of(zoneId)); + var endpoints = controller.applications().clusterEndpoints(Set.of(new DeploymentId(id, zoneId))); if ( ! endpoints.containsKey(zoneId)) return false; @@ -365,7 +366,7 @@ public class InternalStepRunner implements StepRunner { private boolean endpointsAvailable(ApplicationId id, ZoneId zone, DualLogger logger) { logger.log("Attempting to find deployment endpoints ..."); - var endpoints = controller.applications().clusterEndpoints(id, Set.of(zone)); + var endpoints = controller.applications().clusterEndpoints(Set.of(new DeploymentId(id, zone))); if ( ! endpoints.containsKey(zone)) { logger.log("Endpoints not yet ready."); return false; @@ -439,10 +440,14 @@ public class InternalStepRunner implements StepRunner { return Optional.of(aborted); } - Set<ZoneId> zones = controller.jobController().testedZoneAndProductionZones(id.application(), id.type()); + var deployments = controller.applications().requireInstance(id.application()) + .productionDeployments().keySet().stream() + .map(zone -> new DeploymentId(id.application(), zone)) + .collect(Collectors.toSet()); + deployments.add(new DeploymentId(id.application(), id.type().zone(controller.system()))); logger.log("Attempting to find endpoints ..."); - var endpoints = controller.applications().clusterEndpoints(id.application(), zones); + var endpoints = controller.applications().clusterEndpoints(deployments); if ( ! endpoints.containsKey(id.type().zone(controller.system())) && timedOut(id, deployment.get(), endpointTimeout)) { logger.log(WARNING, "Endpoints for the deployment to test vanished again, while it was still active!"); return Optional.of(error); @@ -467,7 +472,7 @@ public class InternalStepRunner implements StepRunner { id.type(), true, endpoints, - controller.applications().contentClustersByZone(id.application(), zones))); + controller.applications().contentClustersByZone(deployments))); return Optional.of(running); } diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java index fcc7271e44b..0e653beb29a 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/JobController.java @@ -499,13 +499,6 @@ public class JobController { return URI.create("http://" + url.getHost() + ":443/"); } - /** Returns a set containing the zone of the deployment tested in the given run, and all production zones for the application. */ - public Set<ZoneId> testedZoneAndProductionZones(ApplicationId id, JobType type) { - return Stream.concat(Stream.of(type.zone(controller.system())), - controller.applications().requireInstance(id).productionDeployments().keySet().stream()) - .collect(Collectors.toSet()); - } - private void prunePackages(TenantAndApplicationId id) { controller.applications().lockApplicationIfPresent(id, application -> { application.get().productionDeployments().values().stream() diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java index b7e9dff579b..5b11fe1a311 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java @@ -1524,12 +1524,26 @@ public class ApplicationApiHandler extends LoggingRequestHandler { } private HttpResponse testConfig(ApplicationId id, JobType type) { - Set<ZoneId> zones = controller.jobController().testedZoneAndProductionZones(id, type); + // TODO jonmv: Support non-default instances as well; requires API change in clients. + ApplicationId defaultInstanceId = TenantAndApplicationId.from(id).defaultInstance(); + var deployments = controller.applications() + .getInstance(defaultInstanceId).stream() + .flatMap(instance -> instance.productionDeployments().keySet().stream()) + .map(zone -> new DeploymentId(defaultInstanceId, zone)) + .collect(Collectors.toSet()); + var testedZone = type.zone(controller.system()); + + // This should not happen, unless one asks for test-config for a production job, which one shouldn't have use for. + if (deployments.stream().anyMatch(deploymentId -> deploymentId.zoneId().equals(testedZone) + && ! deploymentId.applicationId().equals(id))) + throw new IllegalStateException("Conflict: " + testedZone + " contains both default and " + id.instance().value() + " instances"); + + deployments.add(new DeploymentId(id, testedZone)); return new SlimeJsonResponse(testConfigSerializer.configSlime(id, type, false, - controller.applications().clusterEndpoints(id, zones), - controller.applications().contentClustersByZone(id, zones))); + controller.applications().clusterEndpoints(deployments), + controller.applications().contentClustersByZone(deployments))); } private static DeploymentJobs.JobReport toJobReport(String tenantName, String applicationName, Inspector report) { |