mirror of https://github.com/apache/druid.git
Add errorCode to failure type `InternalServerError` (#16186)
Changes: - Use error code `internalServerError` for failures of this type - Remove the error code argument from `InternalServerError.exception()` methods thus fixing a bug in the callers.
This commit is contained in:
parent
cfa2a901b3
commit
323d67a0ac
|
@ -153,7 +153,8 @@ public abstract class K8sTaskAdapter implements TaskAdapter
|
||||||
com.google.common.base.Optional<InputStream> taskBody = taskLogs.streamTaskPayload(getTaskId(from).getOriginalTaskId());
|
com.google.common.base.Optional<InputStream> taskBody = taskLogs.streamTaskPayload(getTaskId(from).getOriginalTaskId());
|
||||||
if (!taskBody.isPresent()) {
|
if (!taskBody.isPresent()) {
|
||||||
throw InternalServerError.exception(
|
throw InternalServerError.exception(
|
||||||
"Could not load task payload from deep storage for job [%s]. Check the overlord logs for any errors in uploading task payload to deep storage.",
|
"Could not load task payload from deep storage for job [%s]."
|
||||||
|
+ " Check the overlord logs for any errors in uploading task payload to deep storage.",
|
||||||
from.getMetadata().getName()
|
from.getMetadata().getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -188,7 +188,8 @@ public class PodTemplateTaskAdapter implements TaskAdapter
|
||||||
com.google.common.base.Optional<InputStream> taskBody = taskLogs.streamTaskPayload(getTaskId(from).getOriginalTaskId());
|
com.google.common.base.Optional<InputStream> taskBody = taskLogs.streamTaskPayload(getTaskId(from).getOriginalTaskId());
|
||||||
if (!taskBody.isPresent()) {
|
if (!taskBody.isPresent()) {
|
||||||
throw InternalServerError.exception(
|
throw InternalServerError.exception(
|
||||||
"Could not load task payload from deep storage for job [%s]. Check the overlord logs for errors uploading task payloads to deep storage.",
|
"Could not load task payload from deep storage for job [%s]."
|
||||||
|
+ " Check the overlord logs for errors uploading task payloads to deep storage.",
|
||||||
from.getMetadata().getName()
|
from.getMetadata().getName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,25 +21,24 @@ package org.apache.druid.error;
|
||||||
|
|
||||||
public class InternalServerError extends BaseFailure
|
public class InternalServerError extends BaseFailure
|
||||||
{
|
{
|
||||||
public static DruidException exception(String errorCode, String msg, Object... args)
|
public static DruidException exception(String msg, Object... args)
|
||||||
{
|
{
|
||||||
return exception(null, errorCode, msg, args);
|
return exception(null, msg, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DruidException exception(Throwable t, String errorCode, String msg, Object... args)
|
public static DruidException exception(Throwable t, String msg, Object... args)
|
||||||
{
|
{
|
||||||
return DruidException.fromFailure(new InternalServerError(t, errorCode, msg, args));
|
return DruidException.fromFailure(new InternalServerError(t, msg, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
private InternalServerError(
|
private InternalServerError(
|
||||||
Throwable t,
|
Throwable t,
|
||||||
String errorCode,
|
|
||||||
String msg,
|
String msg,
|
||||||
Object... args
|
Object... args
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
super(
|
super(
|
||||||
errorCode,
|
"internalServerError",
|
||||||
DruidException.Persona.OPERATOR,
|
DruidException.Persona.OPERATOR,
|
||||||
DruidException.Category.RUNTIME_FAILURE,
|
DruidException.Category.RUNTIME_FAILURE,
|
||||||
t, msg, args
|
t, msg, args
|
||||||
|
|
|
@ -31,14 +31,14 @@ public class InternalServerErrorTest
|
||||||
@Test
|
@Test
|
||||||
public void testAsErrorResponse()
|
public void testAsErrorResponse()
|
||||||
{
|
{
|
||||||
ErrorResponse errorResponse = new ErrorResponse(InternalServerError.exception("runtimeFailure", "Internal Server Error"));
|
ErrorResponse errorResponse = new ErrorResponse(InternalServerError.exception("Internal Server Error"));
|
||||||
final Map<String, Object> asMap = errorResponse.getAsMap();
|
final Map<String, Object> asMap = errorResponse.getAsMap();
|
||||||
|
|
||||||
MatcherAssert.assertThat(
|
MatcherAssert.assertThat(
|
||||||
asMap,
|
asMap,
|
||||||
DruidMatchers.mapMatcher(
|
DruidMatchers.mapMatcher(
|
||||||
"error", "druidException",
|
"error", "druidException",
|
||||||
"errorCode", "runtimeFailure",
|
"errorCode", "internalServerError",
|
||||||
"persona", "OPERATOR",
|
"persona", "OPERATOR",
|
||||||
"category", "RUNTIME_FAILURE",
|
"category", "RUNTIME_FAILURE",
|
||||||
"errorMessage", "Internal Server Error"
|
"errorMessage", "Internal Server Error"
|
||||||
|
@ -52,7 +52,7 @@ public class InternalServerErrorTest
|
||||||
new DruidExceptionMatcher(
|
new DruidExceptionMatcher(
|
||||||
DruidException.Persona.OPERATOR,
|
DruidException.Persona.OPERATOR,
|
||||||
DruidException.Category.RUNTIME_FAILURE,
|
DruidException.Category.RUNTIME_FAILURE,
|
||||||
"runtimeFailure"
|
"internalServerError"
|
||||||
).expectMessageContains("Internal Server Error")
|
).expectMessageContains("Internal Server Error")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue