aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/main
diff options
context:
space:
mode:
authorHarald Musum <musum@yahooinc.com>2023-05-22 14:58:34 +0200
committerGitHub <noreply@github.com>2023-05-22 14:58:34 +0200
commitf8fda07e9542664277e1835c9d6d1fd136ea6b6a (patch)
tree7142bc363c83a669abec26288b83d2225da1c77c /configserver/src/main
parent38601194dc7ece53e180005f10f26c3858956ce6 (diff)
Revert "Revert "Use another exception and error in response when quota is exceed""
Diffstat (limited to 'configserver/src/main')
-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.java3
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java3
3 files changed, 11 insertions, 2 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 3b5269cdf11..c87d77eaf07 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
@@ -53,7 +53,8 @@ public class HttpErrorResponse extends HttpResponse {
LOAD_BALANCER_NOT_READY,
CONFIG_NOT_CONVERGED,
REINDEXING_STATUS_UNAVAILABLE,
- PRECONDITION_FAILED
+ PRECONDITION_FAILED,
+ QUOTA_EXCEEDED
}
public static HttpErrorResponse notFoundError(String msg) {
@@ -120,6 +121,10 @@ public class HttpErrorResponse extends HttpResponse {
return new HttpErrorResponse(PRECONDITION_FAILED, ErrorCode.PRECONDITION_FAILED.name(), msg);
}
+ public static HttpResponse quotaExceeded(String msg) {
+ return new HttpErrorResponse(BAD_REQUEST, ErrorCode.QUOTA_EXCEEDED.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 a0e814f32d8..58651af54f3 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
@@ -5,6 +5,7 @@ import com.yahoo.config.provision.ApplicationLockException;
import com.yahoo.config.provision.CertificateNotReadyException;
import com.yahoo.config.provision.NodeAllocationException;
import com.yahoo.config.provision.ParentHostUnavailableException;
+import com.yahoo.config.provision.QuotaExceededException;
import com.yahoo.config.provision.exception.ActivationConflictException;
import com.yahoo.config.provision.exception.LoadBalancerServiceException;
import com.yahoo.container.jdisc.HttpRequest;
@@ -73,6 +74,8 @@ public class HttpHandler extends ThreadedHttpRequestHandler {
return HttpErrorResponse.reindexingStatusUnavailable(getMessage(e, request));
} catch (PreconditionFailedException e) {
return HttpErrorResponse.preconditionFailed(getMessage(e, request));
+ } catch (QuotaExceededException e) {
+ return HttpErrorResponse.quotaExceeded(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/modelfactory/ModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
index bd1837707d9..4faa475fa08 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java
@@ -14,6 +14,7 @@ import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.ApplicationLockException;
import com.yahoo.config.provision.DockerImage;
import com.yahoo.config.provision.NodeAllocationException;
+import com.yahoo.config.provision.QuotaExceededException;
import com.yahoo.config.provision.TransientException;
import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.server.http.InternalServerException;
@@ -122,7 +123,7 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> {
buildLatestModelForThisMajor, majorVersion));
buildLatestModelForThisMajor = false; // We have successfully built latest model version, do it only for this major
}
- catch (NodeAllocationException | ApplicationLockException | TransientException e) {
+ catch (NodeAllocationException | ApplicationLockException | TransientException | QuotaExceededException e) {
// Don't wrap this exception, and don't try to load other model versions as this is (most likely)
// caused by the state of the system, not the model version/application combination
throw e;