Skip to content

Commit de9d94f

Browse files
[b/407765680] Better UX for dumper connector tasks failures due to la… (#841)
* [b/407765680] Better UX for dumper connector tasks failures due to lack of Kerberos auth * improve logs api usage --------- Co-authored-by: Vladislav Sidorovich <vsidorovich@google.com>
1 parent 6bb9479 commit de9d94f

File tree

1 file changed

+12
-2
lines changed
  • dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper

1 file changed

+12
-2
lines changed

dumper/app/src/main/java/com/google/edwmigration/dumper/application/dumper/TasksRunner.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.google.edwmigration.dumper.application.dumper.task.TaskRunContextOps;
3131
import com.google.edwmigration.dumper.application.dumper.task.TaskSetState;
3232
import com.google.edwmigration.dumper.application.dumper.task.TaskState;
33+
import java.io.IOException;
3334
import java.nio.charset.StandardCharsets;
3435
import java.sql.SQLException;
3536
import java.time.Duration;
@@ -123,6 +124,9 @@ private void logProgress() {
123124
PROGRESS_LOG.info(progressMessage);
124125
}
125126

127+
private static final String ACCESS_CONTROL_EXCEPTION_MSG_SUFFIX =
128+
".AccessControlException: SIMPLE authentication is not enabled. Available:[TOKEN, KERBEROS]";
129+
126130
private <T> T runTask(Task<T> task) throws MetadataDumperUsageException {
127131
try {
128132
CHECK:
@@ -152,10 +156,16 @@ private <T> T runTask(Task<T> task) throws MetadataDumperUsageException {
152156
if (e instanceof MetadataDumperUsageException) throw (MetadataDumperUsageException) e;
153157
if (e instanceof SQLException && e.getCause() instanceof MetadataDumperUsageException)
154158
throw (MetadataDumperUsageException) e.getCause();
159+
if (e instanceof IOException // is it a org.apache.hadoop.security.AccessControlException?
160+
&& e.getMessage().endsWith(ACCESS_CONTROL_EXCEPTION_MSG_SUFFIX)) {
161+
if (!task.handleException(e))
162+
logger.warn("Task failed due to access denied: {}: {}", task, e.getMessage());
163+
}
155164
// TaskGroup is an attempt to get rid of this condition.
156165
// We might need an additional TaskRunner / TaskSupport with an overrideable handleException
157166
// method instead of this runTask() method.
158-
if (!task.handleException(e)) logger.warn("Task failed: " + task + ": " + e, e);
167+
else if (!task.handleException(e))
168+
logger.warn("Task failed: {}: {}", task, e.getMessage(), e);
159169
state.setTaskException(task, TaskState.FAILED, e);
160170
try {
161171
OutputHandle sink = context.newOutputFileHandle(task.getTargetPath() + ".exception.txt");
@@ -166,7 +176,7 @@ private <T> T runTask(Task<T> task) throws MetadataDumperUsageException {
166176
"******************************",
167177
String.valueOf(new DumperDiagnosticQuery(e).call())));
168178
} catch (Exception f) {
169-
logger.warn("Exception-recorder failed: " + f, f);
179+
logger.warn("Exception-recorder failed: {}", f.getMessage(), f);
170180
}
171181
}
172182
return null;

0 commit comments

Comments
 (0)