summaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2022-02-28 12:49:33 +0100
committerJon Marius Venstad <venstad@gmail.com>2022-02-28 12:49:33 +0100
commitd6cab1f38a8f2a044611628bd81df8bf96de9cae (patch)
tree1467a7ac063b65b4ff1e9dc5d8c911a107a4d083 /hosted-api
parent7d786652ca04915475c62c30fad1ba93b2603d78 (diff)
Do not retry failed deployments or submissions
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
index 11a4d096312..3189a2c8e92 100644
--- a/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
+++ b/hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java
@@ -117,7 +117,8 @@ public abstract class ControllerHttpClient {
POST,
new MultiPartStreamer().addJson("submitOptions", metaToJson(submission))
.addFile("applicationZip", submission.applicationZip())
- .addFile("applicationTestZip", submission.applicationTestZip()))));
+ .addFile("applicationTestZip", submission.applicationTestZip())),
+ 1));
}
/** Sends the given deployment to the given application in the given zone, or throws if this fails. */
@@ -125,7 +126,8 @@ public abstract class ControllerHttpClient {
return toDeploymentResult(send(request(HttpRequest.newBuilder(deploymentJobPath(id, zone))
.timeout(Duration.ofMinutes(20)),
POST,
- toDataStream(deployment))));
+ toDataStream(deployment)),
+ 1));
}
/** Deactivates the deployment of the given application in the given zone. */
@@ -333,8 +335,16 @@ public abstract class ControllerHttpClient {
/** Returns a response with a 2XX status code, with up to 10 attempts, or throws. */
private HttpResponse<byte[]> send(HttpRequest request) {
+ return send(request, 10);
+ }
+
+ /** Returns a response with a 2XX status code, after the specified number of attempts, or throws. */
+ private HttpResponse<byte[]> send(HttpRequest request, int attempts) {
+ if (attempts < 1)
+ throw new IllegalStateException("Programming error, attempts must be at least 1");
+
UncheckedIOException thrown = null;
- for (int attempt = 1; attempt <= 10; attempt++) {
+ for (int attempt = 1; attempt <= attempts; attempt++) {
try {
HttpResponse<byte[]> response = client.send(request, ofByteArray());
if (response.statusCode() / 100 == 2)