Unwrap cause from remote ActionTransportExceptions (#52842) (#52878)

And log the cause
This commit is contained in:
David Kyle 2020-02-27 11:58:28 +00:00 committed by GitHub
parent 4a33352a94
commit 6e5e64559a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 9 deletions

View File

@ -98,7 +98,7 @@ public class DataFrameAnalyticsManager {
} }
}, },
error -> task.setFailed(error.getMessage()) error -> task.setFailed(ExceptionsHelper.unwrapCause(error).getMessage())
); );
// Retrieve configuration // Retrieve configuration
@ -148,10 +148,11 @@ public class DataFrameAnalyticsManager {
ActionListener.wrap( ActionListener.wrap(
r-> reindexDataframeAndStartAnalysis(task, config), r-> reindexDataframeAndStartAnalysis(task, config),
e -> { e -> {
if (ExceptionsHelper.unwrapCause(e) instanceof IndexNotFoundException) { Throwable cause = ExceptionsHelper.unwrapCause(e);
if (cause instanceof IndexNotFoundException) {
reindexDataframeAndStartAnalysis(task, config); reindexDataframeAndStartAnalysis(task, config);
} else { } else {
task.setFailed(e.getMessage()); task.setFailed(cause.getMessage());
} }
} }
)); ));
@ -178,7 +179,7 @@ public class DataFrameAnalyticsManager {
Messages.getMessage(Messages.DATA_FRAME_ANALYTICS_AUDIT_FINISHED_REINDEXING, config.getDest().getIndex())); Messages.getMessage(Messages.DATA_FRAME_ANALYTICS_AUDIT_FINISHED_REINDEXING, config.getDest().getIndex()));
startAnalytics(task, config); startAnalytics(task, config);
}, },
error -> task.setFailed(error.getMessage()) error -> task.setFailed(ExceptionsHelper.unwrapCause(error).getMessage())
); );
// Reindex // Reindex
@ -241,15 +242,16 @@ public class DataFrameAnalyticsManager {
task.updatePersistentTaskState(analyzingState, ActionListener.wrap( task.updatePersistentTaskState(analyzingState, ActionListener.wrap(
updatedTask -> processManager.runJob(task, config, dataExtractorFactory), updatedTask -> processManager.runJob(task, config, dataExtractorFactory),
error -> { error -> {
if (ExceptionsHelper.unwrapCause(error) instanceof ResourceNotFoundException) { Throwable cause = ExceptionsHelper.unwrapCause(error);
if (cause instanceof ResourceNotFoundException) {
// Task has stopped // Task has stopped
} else { } else {
task.setFailed(error.getMessage()); task.setFailed(cause.getMessage());
} }
} }
)); ));
}, },
error -> task.setFailed(error.getMessage()) error -> task.setFailed(ExceptionsHelper.unwrapCause(error).getMessage())
); );
ActionListener<RefreshResponse> refreshListener = ActionListener.wrap( ActionListener<RefreshResponse> refreshListener = ActionListener.wrap(

View File

@ -9,6 +9,7 @@ package org.elasticsearch.xpack.transform.transforms;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.apache.lucene.util.SetOnce; import org.apache.lucene.util.SetOnce;
import org.elasticsearch.ExceptionsHelper;
import org.elasticsearch.ResourceNotFoundException; import org.elasticsearch.ResourceNotFoundException;
import org.elasticsearch.Version; import org.elasticsearch.Version;
import org.elasticsearch.action.ActionListener; import org.elasticsearch.action.ActionListener;
@ -279,9 +280,10 @@ public class TransformPersistentTasksExecutor extends PersistentTasksExecutor<Tr
ActionListener<Void> templateCheckListener = ActionListener.wrap( ActionListener<Void> templateCheckListener = ActionListener.wrap(
aVoid -> transformServices.getConfigManager().getTransformConfiguration(transformId, getTransformConfigListener), aVoid -> transformServices.getConfigManager().getTransformConfiguration(transformId, getTransformConfigListener),
error -> { error -> {
Throwable cause = ExceptionsHelper.unwrapCause(error);
String msg = "Failed to create internal index mappings"; String msg = "Failed to create internal index mappings";
logger.error(msg, error); logger.error(msg, cause);
markAsFailed(buildTask, msg); markAsFailed(buildTask, msg + "[" + cause + "]");
} }
); );