Forráskód Böngészése

HDFS-3905. Secure cluster cannot use hftp to an insecure cluster (Daryn Sharp via tgraves)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23@1393699 13f79535-47bb-0310-9956-ffa450edef68
Thomas Graves 12 éve
szülő
commit
8a06b30983

+ 3 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt

@@ -15,6 +15,9 @@ Release 0.23.5 - UNRELEASED
     HDFS-3919. MiniDFSCluster:waitClusterUp can hang forever.
     (Andy Isaacson via eli)
 
+    HDFS-3905. Secure cluster cannot use hftp to an insecure cluster
+    (Daryn Sharp via tgraves)
+
 Release 0.23.4 - UNRELEASED
 
   INCOMPATIBLE CHANGES

+ 19 - 4
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DelegationTokenFetcher.java

@@ -24,6 +24,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.net.ConnectException;
 import java.net.HttpURLConnection;
 import java.net.InetSocketAddress;
 import java.net.URL;
@@ -385,10 +386,24 @@ public class DelegationTokenFetcher {
       return ugi.doAs(
           new PrivilegedExceptionAction<URLConnection>() {
             public URLConnection run() throws IOException {
-              SecurityUtil.fetchServiceTicket(url);
-              URLConnection connection = URLUtils.openConnection(url);
-              connection.connect();
-              return connection;
+              // might not be fatal if secure port doesn't connect because
+              // security may be disabled on remote cluster
+              IOException ioeForTGS = null;
+              try {
+                SecurityUtil.fetchServiceTicket(url);
+              } catch (IOException ioe) {
+                ioeForTGS = ioe;
+              }
+              try {
+                URLConnection connection = URLUtils.openConnection(url);
+                connection.connect();
+                return connection;
+              } catch (ConnectException e) {
+                throw e;
+              } catch (IOException ioe) {
+                // throw TGS exception instead if negotiation fails
+                throw (ioeForTGS != null) ? ioeForTGS : ioe;
+              }
             }
           });
     } catch (InterruptedException ie) {