From 10108f1ccd8bbbd8480a033394cb32dcf5d8b117 Mon Sep 17 00:00:00 2001 From: Jon Marius Venstad Date: Fri, 11 Oct 2019 18:19:11 +0200 Subject: Handle cases where instances in application are not in the deployment spec --- .../yahoo/vespa/hosted/controller/ApplicationController.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'controller-server') 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 0a260bf3ed5..d118239d6a7 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 @@ -464,7 +464,7 @@ public class ApplicationController { // We do this at deployment time for externally built applications, and at submission time // for internally built ones, to be able to return a validation failure message when necessary for (InstanceName instanceName : application.get().instances().keySet()) { - application = withoutDeletedDeployments(application, instanceName); + application = withoutDeletedDeployments(application, instanceName); // Clean up deployment jobs that are no longer referenced by deployment spec DeploymentSpec deploymentSpec = application.get().deploymentSpec(); @@ -630,8 +630,9 @@ public class ApplicationController { private LockedApplication withoutDeletedDeployments(LockedApplication application, InstanceName instance) { DeploymentSpec deploymentSpec = application.get().deploymentSpec(); List deploymentsToRemove = application.get().require(instance).productionDeployments().values().stream() - .filter(deployment -> ! deploymentSpec.requireInstance(instance).includes(deployment.zone().environment(), - Optional.of(deployment.zone().region()))) + .filter(deployment -> deploymentSpec.instance(instance).isEmpty() + || ! deploymentSpec.requireInstance(instance).includes(deployment.zone().environment(), + Optional.of(deployment.zone().region()))) .collect(Collectors.toList()); if (deploymentsToRemove.isEmpty()) return application; @@ -655,7 +656,9 @@ public class ApplicationController { private Instance withoutUnreferencedDeploymentJobs(DeploymentSpec deploymentSpec, Instance instance) { for (JobType job : JobList.from(instance).production().mapToList(JobStatus::type)) { ZoneId zone = job.zone(controller.system()); - if (deploymentSpec.requireInstance(instance.name()).includes(zone.environment(), Optional.of(zone.region()))) + if (deploymentSpec.instance(instance.name()) + .map(spec -> spec.includes(zone.environment(), Optional.of(zone.region()))) + .orElse(false)) continue; instance = instance.withoutDeploymentJob(job); } -- cgit v1.2.3