diff options
7 files changed, 28 insertions, 16 deletions
diff --git a/config-provisioning/src/main/java/com/yahoo/config/provision/OutOfCapacityException.java b/config-provisioning/src/main/java/com/yahoo/config/provision/OutOfCapacityException.java index ee04f4a5615..520caaccdd0 100644 --- a/config-provisioning/src/main/java/com/yahoo/config/provision/OutOfCapacityException.java +++ b/config-provisioning/src/main/java/com/yahoo/config/provision/OutOfCapacityException.java @@ -5,6 +5,7 @@ package com.yahoo.config.provision; * * Exception thrown when we are unable to fulfill the request due to * having too few nodes (of the specified flavor) + * * @author hmusum * */ 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 3574336174f..76c252587ee 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 @@ -18,6 +18,7 @@ import static com.yahoo.jdisc.Response.Status.*; * @since 5.1 */ public class HttpErrorResponse extends HttpResponse { + private static final Logger log = Logger.getLogger(HttpErrorResponse.class.getName()); private final Slime slime = new Slime(); @@ -88,4 +89,5 @@ public class HttpErrorResponse extends HttpResponse { public String getContentType() { return HttpConfigResponse.JSON_CONTENT_TYPE; } + } 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 c379e24854f..ef078ae2c55 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 @@ -49,10 +49,10 @@ public class HttpHandler extends LoggingRequestHandler { return HttpErrorResponse.notFoundError(getMessage(e, request)); } catch (BadRequestException | IllegalArgumentException | IllegalStateException e) { return HttpErrorResponse.badRequest(getMessage(e, request)); - } catch (InvalidApplicationException e) { - return HttpErrorResponse.invalidApplicationPackage(getMessage(e, request)); } catch (OutOfCapacityException e) { return HttpErrorResponse.outOfCapacity(getMessage(e, request)); + } catch (InvalidApplicationException e) { + return HttpErrorResponse.invalidApplicationPackage(getMessage(e, request)); } catch (InternalServerException e) { return HttpErrorResponse.internalServerError(getMessage(e, request)); } catch (UnknownVespaVersionException e) { @@ -62,7 +62,7 @@ public class HttpHandler extends LoggingRequestHandler { } catch (ApplicationLockException e) { return HttpErrorResponse.applicationLockFailure(getMessage(e, request)); } catch (Exception e) { - e.printStackTrace(); + log.log(LogLevel.WARNING, "Unexpected exception handling a config server request", e); return HttpErrorResponse.internalServerError(getMessage(e, request)); } } @@ -75,16 +75,14 @@ public class HttpHandler extends LoggingRequestHandler { } private String getMessage(Exception e, HttpRequest request) { - String message; if (request.getBooleanProperty("debug")) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); - message = sw.toString(); + return sw.toString(); } else { - message = Exceptions.toMessageString(e); + return Exceptions.toMessageString(e); } - return message; } /** diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/InvalidApplicationException.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/InvalidApplicationException.java index 9fec1b0af99..3fa897159e9 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/InvalidApplicationException.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/InvalidApplicationException.java @@ -13,4 +13,5 @@ public class InvalidApplicationException extends RuntimeException { public InvalidApplicationException(String message, Throwable e) { super(message, e); } + } 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 f2b78e9e0dd..4bf1db64f84 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 @@ -6,6 +6,7 @@ import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.model.api.ModelContext; import com.yahoo.config.model.api.ModelFactory; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.OutOfCapacityException; import com.yahoo.config.provision.Rotation; import com.yahoo.config.provision.Version; import com.yahoo.config.provision.Zone; @@ -57,22 +58,25 @@ public abstract class ModelsBuilder<MODELRESULT extends ModelResult> { .distinct() .sorted(Comparator.reverseOrder()) .collect(Collectors.toList()); + List<MODELRESULT> allApplicationModels = new ArrayList<>(); for (int i = 0; i < majorVersions.size(); i++) { try { allApplicationModels.addAll(buildModelVersion(filterByMajorVersion(majorVersions.get(i), versions), applicationId, wantedNodeVespaVersion, applicationPackage)); - // skip old config models after we have found a major version which works - if (allApplicationModels.size() > 0 && allApplicationModels.get(0).getModel().skipOldConfigModels()) - break; + // skip old config models if requested after we have found a major version which works + if (allApplicationModels.size() > 0 && allApplicationModels.get(0).getModel().skipOldConfigModels()) + break; + } + catch (OutOfCapacityException 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; } - catch (RuntimeException e) { // TODO: Make this a specialized exception + catch (RuntimeException e) { boolean isOldestMajor = i == majorVersions.size() - 1; if (isOldestMajor) { - if (e instanceof NoSuchElementException && "No value present".equals(e.getMessage())) { - e.printStackTrace(); - } throw new IllegalArgumentException(applicationId + ": Error loading model", e); } else { log.log(Level.INFO, applicationId + ": Skipping major version " + majorVersions.get(i), e); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java index cd10b031a93..96c0f912fd4 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionPreparer.java @@ -92,13 +92,15 @@ public class SessionPreparer { try { prep.buildModels(); prep.makeResult(); - if ( ! params.isDryRun()) { + if (!params.isDryRun()) { prep.writeStateZK(); prep.writeRotZK(); prep.distribute(); prep.reloadDeployFileDistributor(); } return prep.result(); + } catch (OutOfCapacityException e) { + throw e; } catch (IllegalArgumentException e) { throw new InvalidApplicationException("Invalid application package", e); } diff --git a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java index 502db89bc00..bad123aff82 100644 --- a/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java +++ b/node-repository/src/test/java/com/yahoo/vespa/hosted/provision/restapi/v2/RestApiTest.java @@ -23,6 +23,10 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** + * Test of the nodes/v2 API. + * + * Note: This class is referenced from our operations documentation and must not be renamed/moved without updating that. + * * @author bratseth */ public class RestApiTest { @@ -100,7 +104,7 @@ public class RestApiTest { // PUT nodes ready assertResponse(new Request("http://localhost:8080/nodes/v2/state/dirty/host8.yahoo.com", - new byte[0], Request.Method.PUT), + new byte[0], Request.Method.PUT), "{\"message\":\"Moved host8.yahoo.com to dirty\"}"); assertResponse(new Request("http://localhost:8080/nodes/v2/state/ready/host8.yahoo.com", new byte[0], Request.Method.PUT), |