Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Feature: check for HTTP 413 (Entity too large) errors (#264)
Browse files Browse the repository at this point in the history
  • Loading branch information
luguina authored Jun 20, 2020
1 parent 09e8151 commit 286fc25
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/com/sheepit/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,12 @@ protected Error.Type confirmJob(Job ajob, int checkpoint) {
// no point to retry the request
confirmJobReturnCode = Error.Type.UNKNOWN;
break retryLoop;


case JOB_VALIDATION_IMAGE_TOO_LARGE:
// the client cannot recover from this error (it's server side config) so exit the retry loop
confirmJobReturnCode = Type.IMAGE_TOO_LARGE;
break retryLoop;

default:
// do nothing, try to do a request on the next loop
break;
Expand Down
5 changes: 4 additions & 1 deletion src/com/sheepit/client/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Error {
public enum Type {
// id have to be kept synchronised with the server side.
OK(0), UNKNOWN(99), WRONG_CONFIGURATION(1), AUTHENTICATION_FAILED(2), TOO_OLD_CLIENT(3), SESSION_DISABLED(4), RENDERER_NOT_AVAILABLE(
5), MISSING_RENDERER(6), MISSING_SCENE(7), NOOUTPUTFILE(8), DOWNLOAD_FILE(9), CAN_NOT_CREATE_DIRECTORY(10), NETWORK_ISSUE(11), RENDERER_CRASHED(
5), MISSING_RENDERER(6), MISSING_SCENE(7), NOOUTPUTFILE(8), IMAGE_TOO_LARGE(26), DOWNLOAD_FILE(9), CAN_NOT_CREATE_DIRECTORY(10), NETWORK_ISSUE(11), RENDERER_CRASHED(
12), RENDERER_CRASHED_PYTHON_ERROR(24), RENDERER_OUT_OF_VIDEO_MEMORY(13), RENDERER_OUT_OF_MEMORY(21), RENDERER_KILLED(
14), RENDERER_KILLED_BY_USER(20), RENDERER_KILLED_BY_USER_OVER_TIME(23), RENDERER_KILLED_BY_SERVER(22), RENDERER_MISSING_LIBRARIES(
15), FAILED_TO_EXECUTE(16), OS_NOT_SUPPORTED(17), CPU_NOT_SUPPORTED(18), GPU_NOT_SUPPORTED(19), VALIDATION_FAILED(25),
Expand Down Expand Up @@ -56,6 +56,7 @@ public enum ServerCode {
JOB_VALIDATION_ERROR_MISSING_PARAMETER(300), JOB_VALIDATION_ERROR_BROKEN_MACHINE(301), // in GPU the generated frame is black
JOB_VALIDATION_ERROR_FRAME_IS_NOT_IMAGE(302), JOB_VALIDATION_ERROR_UPLOAD_FAILED(303), JOB_VALIDATION_ERROR_SESSION_DISABLED(
304), // missing heartbeat or broken machine
JOB_VALIDATION_IMAGE_TOO_LARGE(306),

KEEPMEALIVE_STOP_RENDERING(400),

Expand Down Expand Up @@ -124,6 +125,8 @@ public static String humanString(Type in) {
return "Error while downloading project files. Will try another project in a few minutes.";
case NOOUTPUTFILE:
return "Renderer has generated no output file, possibly a wrong project configuration or you are missing required libraries. Will try another project in a few minutes.";
case IMAGE_TOO_LARGE:
return "The generated image is too big to be handled by the server. Will try another project in a few minutes.";
case RENDERER_CRASHED:
return "Renderer has crashed. It's usually due to a bad project or not enough memory. There is nothing you can do about it. Will try another project in a few minutes.";
case RENDERER_CRASHED_PYTHON_ERROR:
Expand Down
6 changes: 6 additions & 0 deletions src/com/sheepit/client/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@ public ServerCode HTTPSendFile(String surl, String file1, int checkpoint) {
else if (r == HttpURLConnection.HTTP_OK && contentType.startsWith("text/html")) {
return ServerCode.ERROR_BAD_RESPONSE;
}
// We don't check all the HTTP 4xx but the 413 in particular, we can always find a huge image larger than whatever configuration we have in the
// server and it's worth to send the error back to the server if this happen
else if (r == HttpURLConnection.HTTP_ENTITY_TOO_LARGE) {
this.log.error(response.body().string());
return ServerCode.JOB_VALIDATION_IMAGE_TOO_LARGE;
}
else {
this.log.error(String.format("Server::HTTPSendFile Unknown response received from server: %s", response.body().string()));
}
Expand Down

0 comments on commit 286fc25

Please sign in to comment.