From 63e08ec071852640babea9e39780327a0907712a Mon Sep 17 00:00:00 2001 From: Sunil G Date: Mon, 30 Jul 2018 14:48:04 +0530 Subject: [PATCH] YARN-8591. [ATSv2] NPE while checking for entity acl in non-secure cluster. Contributed by Rohith Sharma K S. --- .../timelineservice/reader/TimelineReaderWebServices.java | 3 ++- .../reader/TestTimelineReaderWebServicesBasicAcl.java | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java index 7f96bfb6371..b10b705bb61 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/main/java/org/apache/hadoop/yarn/server/timelineservice/reader/TimelineReaderWebServices.java @@ -3532,7 +3532,8 @@ public class TimelineReaderWebServices { static boolean checkAccess(TimelineReaderManager readerManager, UserGroupInformation ugi, String entityUser) { if (isDisplayEntityPerUserFilterEnabled(readerManager.getConfig())) { - if (!validateAuthUserWithEntityUser(readerManager, ugi, entityUser)) { + if (ugi != null && !validateAuthUserWithEntityUser(readerManager, ugi, + entityUser)) { String userName = ugi.getShortUserName(); String msg = "User " + userName + " is not allowed to read TimelineService V2 data."; diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesBasicAcl.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesBasicAcl.java index 4239bf0460d..6651457ff75 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesBasicAcl.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-timelineservice/src/test/java/org/apache/hadoop/yarn/server/timelineservice/reader/TestTimelineReaderWebServicesBasicAcl.java @@ -88,6 +88,10 @@ public class TestTimelineReaderWebServicesBasicAcl { Assert.assertFalse(TimelineReaderWebServices .validateAuthUserWithEntityUser(manager, null, user1)); + // true because ugi is null + Assert.assertTrue( + TimelineReaderWebServices.checkAccess(manager, null, user1)); + // incoming ugi is admin asking for entity owner user1 Assert.assertTrue( TimelineReaderWebServices.checkAccess(manager, adminUgi, user1));