Handle cases where instances in application are not in the deployment spec
@@ -630,7 +630,8 @@ public class ApplicationController {
private LockedApplication withoutDeletedDeployments(LockedApplication application, InstanceName instance) {
DeploymentSpec deploymentSpec = application.get().deploymentSpec();
List<Deployment> deploymentsToRemove = application.get().require(instance).productionDeployments().values().stream()
- .filter(deployment -> ! deploymentSpec.requireInstance(instance).includes(deployment.zone().environment(),
+ .filter(deployment -> deploymentSpec.instance(instance).isEmpty()
+ || ! deploymentSpec.requireInstance(instance).includes(deployment.zone().environment(),
Optional.of(deployment.zone().region())))
.collect(Collectors.toList());
@@ -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);
}
