aboutsummaryrefslogtreecommitdiffstats
path: root/vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2019-09-12 12:59:54 +0200
committerGitHub <noreply@github.com>2019-09-12 12:59:54 +0200
commit4c4072e53213f75c739bbfc152e884cab94bdf3c (patch)
tree2c50bf414541b679c664a4ef10f466d01593d5e3 /vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java
parentcc8a4ee468a4a403d1be54260259b060851b35e6 (diff)
parent10cc1a0232d7f09116fb9eeaaa646c67ce3c29d5 (diff)
Merge pull request #10590 from vespa-engine/jvenstad/reflect-deployment-status-in-plugin-exit
Reflect deployment job status when plugin exists
Diffstat (limited to 'vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java')
-rw-r--r--vespa-maven-plugin/src/main/java/ai/vespa/hosted/plugin/DeployMojo.java20
1 files changed, 17 insertions, 3 deletions
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);