HDFS-14140. JournalNodeSyncer authentication is failing in secure cluster. Contributed by Surendra Singh Lilhore.

Signed-off-by: Wei-Chiu Chuang <weichiu@apache.org>
This commit is contained in:
Surendra Singh Lilhore 2019-02-07 16:43:55 -08:00 committed by Wei-Chiu Chuang
parent 1f1655028e
commit 4be87353e3

View File

@ -38,6 +38,7 @@
import org.apache.hadoop.ipc.ProtobufRpcEngine; import org.apache.hadoop.ipc.ProtobufRpcEngine;
import org.apache.hadoop.ipc.RPC; import org.apache.hadoop.ipc.RPC;
import org.apache.hadoop.security.SecurityUtil; import org.apache.hadoop.security.SecurityUtil;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.util.Daemon; import org.apache.hadoop.util.Daemon;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -439,15 +440,23 @@ private boolean downloadMissingLogSegment(URL url, RemoteEditLog log)
File tmpEditsFile = jnStorage.getTemporaryEditsFile( File tmpEditsFile = jnStorage.getTemporaryEditsFile(
log.getStartTxId(), log.getEndTxId()); log.getStartTxId(), log.getEndTxId());
try { if (!SecurityUtil.doAsLoginUser(() -> {
Util.doGetUrl(url, ImmutableList.of(tmpEditsFile), jnStorage, false, if (UserGroupInformation.isSecurityEnabled()) {
logSegmentTransferTimeout, throttler); UserGroupInformation.getCurrentUser().checkTGTAndReloginFromKeytab();
} catch (IOException e) {
LOG.error("Download of Edit Log file for Syncing failed. Deleting temp " +
"file: " + tmpEditsFile);
if (!tmpEditsFile.delete()) {
LOG.warn("Deleting " + tmpEditsFile + " has failed");
} }
try {
Util.doGetUrl(url, ImmutableList.of(tmpEditsFile), jnStorage, false,
logSegmentTransferTimeout, throttler);
} catch (IOException e) {
LOG.error("Download of Edit Log file for Syncing failed. Deleting temp "
+ "file: " + tmpEditsFile, e);
if (!tmpEditsFile.delete()) {
LOG.warn("Deleting " + tmpEditsFile + " has failed");
}
return false;
}
return true;
})) {
return false; return false;
} }
LOG.info("Downloaded file " + tmpEditsFile.getName() + " of size " + LOG.info("Downloaded file " + tmpEditsFile.getName() + " of size " +