aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2019-09-10 15:21:43 +0200
committerJon Marius Venstad <venstad@gmail.com>2019-09-10 15:21:43 +0200
commit10cc1a0232d7f09116fb9eeaaa646c67ce3c29d5 (patch)
tree8d922b444f6d064f09b7ea40dbe583a2fc2e9a0e /vespa-maven-plugin
parent8aed64b0c2e9fd6e37114c42bee64b512f73bef1 (diff)
Reflect deployment job status when plugin exists
Diffstat (limited to 'vespa-maven-plugin')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java6
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java20
2 files changed, 22 insertions, 4 deletions
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
index e2bbbb86706..b7c49b289fc 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/AbstractVespaMojo.java
@@ -4,6 +4,7 @@ import ai.vespa.hosted.api.ControllerHttpClient;
import com.yahoo.config.provision.ApplicationId;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
@@ -44,11 +45,14 @@ public abstract class AbstractVespaMojo extends AbstractMojo {
protected ControllerHttpClient controller;
@Override
- public final void execute() throws MojoExecutionException {
+ public final void execute() throws MojoExecutionException, MojoFailureException {
try {
setup();
doExecute();
}
+ catch (MojoFailureException | MojoExecutionException e) {
+ throw e;
+ }
catch (Exception e) {
throw new MojoExecutionException("Execution failed for application '" + id + "':", e);
}
diff --git a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
index 9ef31cafb1b..7deffd37a79 100644
--- a/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
+++ b/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
@@ -5,6 +5,8 @@ import ai.vespa.hosted.api.DeploymentLog;
import ai.vespa.hosted.api.DeploymentResult;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.zone.ZoneId;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
@@ -30,7 +32,7 @@ public class DeployMojo extends AbstractVespaDeploymentMojo {
private boolean follow;
@Override
- protected void doExecute() {
+ protected void doExecute() throws MojoFailureException, MojoExecutionException {
Deployment deployment = Deployment.ofPackage(Paths.get(firstNonBlank(applicationZip,
projectPathOf("target", "application.zip"))));
if (vespaVersion != null) deployment = deployment.atVersion(vespaVersion);
@@ -42,10 +44,11 @@ public class DeployMojo extends AbstractVespaDeploymentMojo {
if (follow) tailLogs(id, zone, result.run());
}
- private void tailLogs(ApplicationId id, ZoneId zone, long run) {
+ private void tailLogs(ApplicationId id, ZoneId zone, long run) throws MojoFailureException, MojoExecutionException {
long last = -1;
+ DeploymentLog log;
while (true) {
- DeploymentLog log = controller.deploymentLog(id, zone, run, last);
+ log = controller.deploymentLog(id, zone, run, last);
for (DeploymentLog.Entry entry : log.entries())
print(entry);
last = log.last().orElse(last);
@@ -61,6 +64,17 @@ public class DeployMojo extends AbstractVespaDeploymentMojo {
break;
}
}
+ switch (log.status()) {
+ case success: return;
+ case error: throw new MojoExecutionException("Unexpected error during deployment; see log for details");
+ case aborted: throw new MojoFailureException("Deployment was aborted, probably by a newer deployment");
+ case outOfCapacity: throw new MojoFailureException("No capacity left in zone; please contact the Vespa team");
+ case deploymentFailed: throw new MojoFailureException("Deployment failed; see log for details");
+ case installationFailed: throw new MojoFailureException("Installation failed; see Vespa log for details");
+ case running: throw new MojoFailureException("Deployment not completed");
+ case testFailure: throw new IllegalStateException("Unexpected status; tests are not run for manual deployments");
+ default: throw new IllegalArgumentException("Unexpected status '" + log.status() + "'");
+ }
}
private static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss").withZone(ZoneOffset.UTC);