Repository: hadoop Updated Branches: refs/heads/branch-3.0 2caf69deb -> fa01a8fa0
HADOOP-15864. Job submitter / executor fail when SBN domain name can not resolved. Contributed by He Xiaoqiao. (cherry picked from commit fb2b72e6fce019130e10964a644b94cddbab1c06) (cherry picked from commit fd02c501c0cea3ec55956e11b390111519cedc00) (cherry picked from commit ef9f8ca13d8dca8031c045bad801fceb3e00aa15) Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/fa01a8fa Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/fa01a8fa Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/fa01a8fa Branch: refs/heads/branch-3.0 Commit: fa01a8fa0e345c533e843504743baa00020be706 Parents: 2caf69d Author: Wei-Chiu Chuang <[email protected]> Authored: Thu Oct 25 09:33:31 2018 -0700 Committer: Wei-Chiu Chuang <[email protected]> Committed: Thu Oct 25 09:38:26 2018 -0700 ---------------------------------------------------------------------- .../apache/hadoop/security/SecurityUtil.java | 9 ++++---- .../namenode/ha/TestDelegationTokensWithHA.java | 23 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hadoop/blob/fa01a8fa/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java ---------------------------------------------------------------------- diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java index 20e8754..45c2f9b 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SecurityUtil.java @@ -420,7 +420,7 @@ public final class SecurityUtil { */ public static void setTokenService(Token<?> token, InetSocketAddress addr) { Text service = buildTokenService(addr); - if (token != null) { + if (token != null && service != null) { token.setService(service); if (LOG.isDebugEnabled()) { LOG.debug("Acquired token "+token); // Token#toString() prints service @@ -440,9 +440,10 @@ public final class SecurityUtil { String host = null; if (useIpForTokenService) { if (addr.isUnresolved()) { // host has no ip address - throw new IllegalArgumentException( - new UnknownHostException(addr.getHostName()) - ); + LOG.warn("unable to resolve host name " + addr + + ". Failure to construct a correct token service " + + "name may result in operation failures"); + return null; } host = addr.getAddress().getHostAddress(); } else { http://git-wip-us.apache.org/repos/asf/hadoop/blob/fa01a8fa/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java ---------------------------------------------------------------------- diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java index ca44c79..087fba1 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestDelegationTokensWithHA.java @@ -332,6 +332,29 @@ public class TestDelegationTokensWithHA { } } + @Test(timeout = 300000) + public void testHAUtilClonesDTsDomainNameResolvedFail() throws Exception { + final Token<DelegationTokenIdentifier> token = + getDelegationToken(fs, "JobTracker"); + + UserGroupInformation ugi = UserGroupInformation.createRemoteUser("test"); + + URI haUri = new URI("hdfs://my-ha-uri/"); + token.setService(HAUtilClient.buildTokenServiceForLogicalUri(haUri, + HdfsConstants.HDFS_URI_SCHEME)); + ugi.addToken(token); + + Collection<InetSocketAddress> nnAddrs = new HashSet<InetSocketAddress>(); + nnAddrs.add(new InetSocketAddress("domainname.doesnot.exist", + nn0.getNameNodeAddress().getPort())); + nnAddrs.add(new InetSocketAddress("localhost", + nn1.getNameNodeAddress().getPort())); + HAUtilClient.cloneDelegationTokenForLogicalUri(ugi, haUri, nnAddrs); + + Collection<Token<? extends TokenIdentifier>> tokens = ugi.getTokens(); + assertEquals(3, tokens.size()); + } + /** * HDFS-3062: DistributedFileSystem.getCanonicalServiceName() throws an * exception if the URI is a logical URI. This bug fails the combination of --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
