From f8fda07e9542664277e1835c9d6d1fd136ea6b6a Mon Sep 17 00:00:00 2001 From: Harald Musum Date: Mon, 22 May 2023 14:58:34 +0200 Subject: Revert "Revert "Use another exception and error in response when quota is exceed"" --- .../java/com/yahoo/vespa/config/server/http/HttpErrorResponse.java | 7 ++++++- .../main/java/com/yahoo/vespa/config/server/http/HttpHandler.java | 3 +++ .../com/yahoo/vespa/config/server/modelfactory/ModelsBuilder.java | 3 ++- 3 files changed, 11 insertions(+), 2 deletions(-) (limited to 'configserver/src/main') 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 { 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; -- cgit v1.2.3