Skip to content

Commit 1539e85

Browse files
YARN-11837. RM UI2 cannot show logs for non-MapReduce jobs with MR ACLs enabled. (apache#7824) Contributed Susheel Gupta.
* YARN-11837: RM UI2 cannot show logs for non-MapReduce jobs with MR ACLs enabled Signed-off-by: Shilun Fan <slfan1989@apache.org>
1 parent d916f26 commit 1539e85

File tree

1 file changed

+19
-2
lines changed
  • hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp

1 file changed

+19
-2
lines changed

hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-hs/src/main/java/org/apache/hadoop/mapreduce/v2/hs/webapp/HsWebServices.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,14 @@
8383
import org.apache.hadoop.yarn.webapp.NotFoundException;
8484
import org.apache.hadoop.yarn.webapp.WebApp;
8585

86+
import org.slf4j.Logger;
87+
import org.slf4j.LoggerFactory;
8688
import org.apache.hadoop.classification.VisibleForTesting;
8789

8890
@Singleton
8991
@Path("/ws/v1/history")
9092
public class HsWebServices extends WebServices {
93+
private static final Logger LOG = LoggerFactory.getLogger(HsWebServices.class);
9194
private final HistoryContext ctx;
9295
private WebApp webapp;
9396
private LogServlet logServlet;
@@ -127,8 +130,22 @@ private void checkAccess(Job job, HttpServletRequest request) {
127130
}
128131
}
129132
private void checkAccess(String containerIdStr, HttpServletRequest hsr) {
130-
if (mrAclsEnabled) {
131-
checkAccess(AMWebServices.getJobFromContainerIdString(containerIdStr, ctx), hsr);
133+
// Apply MR ACLs only if the container belongs to a MapReduce job.
134+
// For non-MapReduce jobs, no corresponding Job will be found,
135+
// so ACLs are not enforced.
136+
if (mrAclsEnabled && isMRJobContainer(containerIdStr)) {
137+
Job job = AMWebServices.getJobFromContainerIdString(containerIdStr, ctx);
138+
checkAccess(job, hsr);
139+
}
140+
}
141+
142+
private boolean isMRJobContainer(String containerIdStr) {
143+
try {
144+
AMWebServices.getJobFromContainerIdString(containerIdStr, ctx);
145+
return true;
146+
} catch (NotFoundException e) {
147+
LOG.trace("Container {} does not belong to a MapReduce job", containerIdStr);
148+
return false;
132149
}
133150
}
134151

0 commit comments

Comments
 (0)