You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ey...@apache.org on 2019/03/18 17:17:52 UTC
[hadoop] branch trunk updated: YARN-9385. Fixed ApiServiceClient to
use current UGI. Contributed by Eric Yang
This is an automated email from the ASF dual-hosted git repository.
eyang pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git
The following commit(s) were added to refs/heads/trunk by this push:
new 19b22c4 YARN-9385. Fixed ApiServiceClient to use current UGI. Contributed by Eric Yang
19b22c4 is described below
commit 19b22c4385a8cf0f89a2ad939380cfd3f033ffdc
Author: Eric Yang <ey...@apache.org>
AuthorDate: Mon Mar 18 13:16:34 2019 -0400
YARN-9385. Fixed ApiServiceClient to use current UGI.
Contributed by Eric Yang
---
.../apache/hadoop/yarn/service/client/ApiServiceClient.java | 13 ++++++++-----
.../hadoop/yarn/service/client/TestApiServiceClient.java | 9 +++++++++
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/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/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
index 008f497..94f03c3 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/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/hadoop-yarn-services-api/src/main/java/org/apache/hadoop/yarn/service/client/ApiServiceClient.java
@@ -151,7 +151,7 @@ public class ApiServiceClient extends AppAdminClient {
* @return URI to API Service
* @throws IOException
*/
- private String getServicePath(String appName) throws IOException {
+ protected String getServicePath(String appName) throws IOException {
String url = getRMWebAddress();
StringBuilder api = new StringBuilder();
api.append(url)
@@ -203,12 +203,15 @@ public class ApiServiceClient extends AppAdminClient {
return api.toString();
}
- private void appendUserNameIfRequired(StringBuilder builder) {
+ private void appendUserNameIfRequired(StringBuilder builder)
+ throws IOException {
Configuration conf = getConfig();
- if (conf.get("hadoop.http.authentication.type").equalsIgnoreCase(
- "simple")) {
+ if (conf.get("hadoop.http.authentication.type")
+ .equalsIgnoreCase("simple")) {
+ String username = UserGroupInformation.getCurrentUser()
+ .getShortUserName();
builder.append("?user.name=").append(UrlEncoded
- .encodeString(System.getProperty("user.name")));
+ .encodeString(username));
}
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/client/TestApiServiceClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/client/TestApiServiceClient.java
index 6cf0880..0ffeb45 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/client/TestApiServiceClient.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-applications/hadoop-yarn-services/hadoop-yarn-services-api/src/test/java/org/apache/hadoop/yarn/service/client/TestApiServiceClient.java
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.google.common.collect.Lists;
+
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.yarn.exceptions.YarnException;
import org.eclipse.jetty.server.Server;
@@ -310,5 +311,13 @@ public class TestApiServiceClient {
}
}
+ @Test
+ public void testNoneSecureApiClient() throws IOException {
+ String url = asc.getServicePath("/foobar");
+ assertTrue("User.name flag is missing in service path.",
+ url.contains("user.name"));
+ assertTrue("User.name flag is not matching JVM user.",
+ url.contains(System.getProperty("user.name")));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org