summaryrefslogtreecommitdiffstats
path: root/hosted-api
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2023-01-02 12:07:11 +0100
committerjonmv <venstad@gmail.com>2023-01-02 12:07:11 +0100
commitcbecbae85a9d5a7160c6cfcecce46be16c9dfcc3 (patch)
treeb139a2b7d3ac377c853a026308ab7bce39eb0751 /hosted-api
parent511829756d97ff029e39e3d3ceedb6517ff5d5d9 (diff)
Always retry connection timeouts a few times, against controller
Diffstat (limited to 'hosted-api')
-rw-r--r--hosted-api/src/main/java/ai/vespa/hosted/api/ControllerHttpClient.java7
1 files changed, 5 insertions, 2 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 3fdcf0e18d8..0c84404208c 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
@@ -27,6 +27,7 @@ import java.io.UncheckedIOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
+import java.net.http.HttpConnectTimeoutException;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.file.Files;
@@ -359,7 +360,7 @@ public abstract class ControllerHttpClient {
throw new IllegalStateException("Programming error, attempts must be at least 1");
UncheckedIOException thrown = null;
- for (int attempt = 1; attempt <= attempts; attempt++) {
+ for (int attempt = 1, connectionRetries = 3; attempt <= attempts; attempt++) {
try {
HttpResponse<byte[]> response = client.send(request, ofByteArray());
if (response.statusCode() / 100 == 2)
@@ -392,6 +393,8 @@ public abstract class ControllerHttpClient {
catch (InterruptedException f) {
throw new RuntimeException(f);
}
+
+ if (e instanceof HttpConnectTimeoutException && --connectionRetries > 0) --attempt;
}
catch (InterruptedException e) {
throw new RuntimeException(e);
@@ -409,7 +412,7 @@ public abstract class ControllerHttpClient {
}
}
- /** Returns a JSON representation of the deployment meta data. */
+ /** Returns a JSON representation of the deployment metadata. */
private static String metaToJson(Deployment deployment) {
Slime slime = new Slime();
Cursor rootObject = slime.setObject();