hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jia...@apache.org
Subject hadoop git commit: YARN-7889. Missing kerberos token when check for RM REST API availability. Contributed by Eric Yang
Date Tue, 06 Feb 2018 06:56:29 GMT
Repository: hadoop
Updated Branches:
  refs/heads/trunk a196ee936 -> 87429affc


YARN-7889. Missing kerberos token when check for RM REST API availability. Contributed by
Eric Yang


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/87429aff
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/87429aff
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/87429aff

Branch: refs/heads/trunk
Commit: 87429affcea2de61791c1b048b6db8c8275de051
Parents: a196ee9
Author: Jian He <jianhe@apache.org>
Authored: Mon Feb 5 22:55:56 2018 -0800
Committer: Jian He <jianhe@apache.org>
Committed: Mon Feb 5 22:56:25 2018 -0800

----------------------------------------------------------------------
 .../yarn/service/client/ApiServiceClient.java   | 41 ++++++++++++++------
 1 file changed, 29 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/87429aff/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
index cb91946..49702e3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
@@ -87,21 +87,38 @@ public class ApiServiceClient extends AppAdminClient {
       rmAddress = conf
           .get("yarn.resourcemanager.webapp.https.address");
     }
-
+    boolean useKerberos = UserGroupInformation.isSecurityEnabled();
     List<String> rmServers = RMHAUtils
         .getRMHAWebappAddresses(new YarnConfiguration(conf));
     for (String host : rmServers) {
-      StringBuilder sb = new StringBuilder();
-      sb.append(scheme);
-      sb.append(host);
-      sb.append(path);
-      Client client = Client.create();
-      WebResource webResource = client
-          .resource(sb.toString());
-      String test = webResource.get(String.class);
-      if (test.contains("hadoop_version")) {
-        rmAddress = host;
-        break;
+      try {
+        Client client = Client.create();
+        StringBuilder sb = new StringBuilder();
+        sb.append(scheme);
+        sb.append(host);
+        sb.append(path);
+        if (!useKerberos) {
+          try {
+            String username = UserGroupInformation.getCurrentUser().getShortUserName();
+            sb.append("?user.name=");
+            sb.append(username);
+          } catch (IOException e) {
+            LOG.debug("Fail to resolve username: {}", e);
+          }
+        }
+        WebResource webResource = client
+            .resource(sb.toString());
+        if (useKerberos) {
+          AuthenticatedURL.Token token = new AuthenticatedURL.Token();
+          webResource.header("WWW-Authenticate", token);
+        }
+        ClientResponse test = webResource.get(ClientResponse.class);
+        if (test.getStatus() == 200) {
+          rmAddress = host;
+          break;
+        }
+      } catch (Exception e) {
+        LOG.debug("Fail to connect to: "+host, e);
       }
     }
     return scheme+rmAddress;


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org


Mime
View raw message