summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@oath.com>2018-10-24 11:24:29 +0200
committerGitHub <noreply@github.com>2018-10-24 11:24:29 +0200
commit6ee03c97c4ac85ca43e9586118a8025535e3ee6b (patch)
tree6d26e6fd59fc5ad0ecbbbe9339f0dc4498597ebc
parent9cce1131255e70e049a878a0b33c2ced6621d62f (diff)
parentf262ab31b25bb240ffa7d4b54034d13f1fcc7a0e (diff)
Merge pull request #7434 from vespa-engine/jvenstad/throw-and-catch
Catch the right exception
-rw-r--r--controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/ApplicationController.java14
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java2
3 files changed, 9 insertions, 11 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
index 15ee3724b6c..1dff20c77be 100644
--- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
+++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServer.java
@@ -29,11 +29,11 @@ public interface ConfigServer {
PreparedApplication deploy(DeploymentId deployment, DeployOptions deployOptions, Set<String> rotationCnames, Set<String> rotationNames, byte[] content);
- void restart(DeploymentId deployment, Optional<Hostname> hostname) throws NoInstanceException;
+ void restart(DeploymentId deployment, Optional<Hostname> hostname);
void deactivate(DeploymentId deployment) throws NoInstanceException;
- boolean isSuspended(DeploymentId deployment) throws NoInstanceException;
+ boolean isSuspended(DeploymentId deployment);
ApplicationView getApplicationView(String tenantName, String applicationName, String instanceName, String environment, String region);
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 26110c9800e..21afe1b0778 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
@@ -22,6 +22,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.BuildService;
import com.yahoo.vespa.hosted.controller.api.integration.athenz.AthenzClientFactory;
import com.yahoo.vespa.hosted.controller.api.integration.athenz.ZmsClient;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServer;
+import com.yahoo.vespa.hosted.controller.api.integration.configserver.ConfigServerException;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.Log;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.NoInstanceException;
import com.yahoo.vespa.hosted.controller.api.integration.configserver.PrepareResponse;
@@ -602,12 +603,7 @@ public class ApplicationController {
* @param hostname If non-empty, restart will only be scheduled for this host
*/
public void restart(DeploymentId deploymentId, Optional<Hostname> hostname) {
- try {
- configServer.restart(deploymentId, hostname);
- }
- catch (NoInstanceException e) {
- throw new IllegalArgumentException("Could not restart " + deploymentId + ": No such deployment");
- }
+ configServer.restart(deploymentId, hostname);
}
/**
@@ -618,8 +614,10 @@ public class ApplicationController {
try {
return configServer.isSuspended(deploymentId);
}
- catch (NoInstanceException e) {
- throw new IllegalArgumentException("Could not check suspension of " + deploymentId + ": No such deployment");
+ catch (ConfigServerException e) {
+ if (e.getErrorCode() == ConfigServerException.ErrorCode.NOT_FOUND)
+ return false;
+ throw e;
}
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
index ef74498a50f..cf9b2370671 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/DeploymentTrigger.java
@@ -362,7 +362,7 @@ public class DeploymentTrigger {
}
private boolean isSuspendedInAnotherZone(Application application, ZoneId zone) {
- for (Deployment deployment : application.deployments().values()) {
+ for (Deployment deployment : application.productionDeployments().values()) {
if ( ! deployment.zone().equals(zone)
&& controller.applications().isSuspended(new DeploymentId(application.id(), deployment.zone())))
return true;