aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2022-10-05 16:21:57 +0200
committerGitHub <noreply@github.com>2022-10-05 16:21:57 +0200
commit24c70d22397fad2c2d5d2e8b45d7da664283fd85 (patch)
tree502de41321b49ddcff26015d31d94975295001e2
parent70bc66e4cc74f00e528b945fc90786defd2eb88f (diff)
parented0e57ad7344a61894bc679bdd87f03e3eb53f17 (diff)
Merge pull request #24315 from vespa-engine/mpolden/unavailable-reindexing-statusv8.64.13
Return 409 if reindexing status is unavailable
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java7
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java2
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/ReindexingStatusException.java16
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java16
4 files changed, 37 insertions, 4 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
index 9b3b3cef5b5..40ce16145e7 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java
@@ -50,7 +50,8 @@ public class HttpErrorResponse extends HttpResponse {
PARENT_HOST_NOT_READY,
CERTIFICATE_NOT_READY,
LOAD_BALANCER_NOT_READY,
- CONFIG_NOT_CONVERGED
+ CONFIG_NOT_CONVERGED,
+ REINDEXING_STATUS_UNAVAILABLE
}
public static HttpErrorResponse notFoundError(String msg) {
@@ -109,6 +110,10 @@ public class HttpErrorResponse extends HttpResponse {
return new HttpErrorResponse(CONFLICT, ErrorCode.LOAD_BALANCER_NOT_READY.name(), msg);
}
+ public static HttpResponse reindexingStatusUnavailable(String msg) {
+ return new HttpErrorResponse(CONFLICT, ErrorCode.REINDEXING_STATUS_UNAVAILABLE.name(), msg);
+ }
+
@Override
public void render(OutputStream stream) throws IOException {
new JsonFormat(true).encode(stream, slime);
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
index 53dbda9c4d1..25ae21f3383 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpHandler.java
@@ -68,6 +68,8 @@ public class HttpHandler extends ThreadedHttpRequestHandler {
return HttpErrorResponse.configNotConverged(getMessage(e, request));
} catch (LoadBalancerServiceException e) {
return HttpErrorResponse.loadBalancerNotReady(getMessage(e, request));
+ } catch (ReindexingStatusException e) {
+ return HttpErrorResponse.reindexingStatusUnavailable(getMessage(e, request));
} catch (Exception e) {
log.log(Level.WARNING, "Unexpected exception handling a config server request", e);
return HttpErrorResponse.internalServerError(getMessage(e, request));
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/ReindexingStatusException.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ReindexingStatusException.java
new file mode 100644
index 00000000000..4f990fcfe6d
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/ReindexingStatusException.java
@@ -0,0 +1,16 @@
+// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server.http;
+
+/**
+ * Exception indicating that the reindexing status for an application is currently unavailable, e.g. if the cluster is
+ * recently configured and its nodes are not yet up.
+ *
+ * @author mpolden
+ */
+public class ReindexingStatusException extends RuntimeException {
+
+ public ReindexingStatusException(String message) {
+ super(message);
+ }
+
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
index fc33830e707..8afffd93a29 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java
@@ -24,12 +24,15 @@ import com.yahoo.slime.Cursor;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.text.StringUtilities;
import com.yahoo.vespa.config.server.ApplicationRepository;
+import com.yahoo.vespa.config.server.application.ApplicationReindexing;
+import com.yahoo.vespa.config.server.application.ClusterReindexing;
import com.yahoo.vespa.config.server.application.ConfigConvergenceChecker;
import com.yahoo.vespa.config.server.http.ContentHandler;
import com.yahoo.vespa.config.server.http.ContentRequest;
import com.yahoo.vespa.config.server.http.HttpHandler;
import com.yahoo.vespa.config.server.http.JSONResponse;
import com.yahoo.vespa.config.server.http.NotFoundException;
+import com.yahoo.vespa.config.server.http.ReindexingStatusException;
import com.yahoo.vespa.config.server.http.v2.request.ApplicationContentRequest;
import com.yahoo.vespa.config.server.http.v2.response.ApplicationSuspendedResponse;
import com.yahoo.vespa.config.server.http.v2.response.DeleteApplicationResponse;
@@ -39,6 +42,7 @@ import com.yahoo.vespa.config.server.http.v2.response.ReindexingResponse;
import com.yahoo.vespa.config.server.tenant.Tenant;
import java.io.IOException;
+import java.io.UncheckedIOException;
import java.net.URI;
import java.time.Duration;
import java.time.Instant;
@@ -296,9 +300,15 @@ public class ApplicationHandler extends HttpHandler {
if (tenant == null)
throw new NotFoundException("Tenant '" + applicationId.tenant().value() + "' not found");
- return new ReindexingResponse(getActiveModelOrThrow(applicationId).documentTypesByCluster(),
- applicationRepository.getReindexing(applicationId),
- applicationRepository.getClusterReindexingStatus(applicationId));
+ try {
+ Map<String, Set<String>> documentTypes = getActiveModelOrThrow(applicationId).documentTypesByCluster();
+ ApplicationReindexing reindexing = applicationRepository.getReindexing(applicationId);
+ Map<String, ClusterReindexing> clusters = applicationRepository.getClusterReindexingStatus(applicationId);
+ return new ReindexingResponse(documentTypes, reindexing, clusters);
+ } catch (UncheckedIOException e) {
+ throw new ReindexingStatusException("Reindexing status for '" + applicationId +
+ "' is currently unavailable");
+ }
}
private HttpResponse restart(ApplicationId applicationId, HttpRequest request) {