|
83 | 83 | import org.apache.hadoop.yarn.webapp.NotFoundException;
|
84 | 84 | import org.apache.hadoop.yarn.webapp.WebApp;
|
85 | 85 |
|
| 86 | +import org.slf4j.Logger; |
| 87 | +import org.slf4j.LoggerFactory; |
86 | 88 | import org.apache.hadoop.classification.VisibleForTesting;
|
87 | 89 |
|
88 | 90 | @Singleton
|
89 | 91 | @Path("/ws/v1/history")
|
90 | 92 | public class HsWebServices extends WebServices {
|
| 93 | + private static final Logger LOG = LoggerFactory.getLogger(HsWebServices.class); |
91 | 94 | private final HistoryContext ctx;
|
92 | 95 | private WebApp webapp;
|
93 | 96 | private LogServlet logServlet;
|
@@ -127,8 +130,22 @@ private void checkAccess(Job job, HttpServletRequest request) {
|
127 | 130 | }
|
128 | 131 | }
|
129 | 132 | 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; |
132 | 149 | }
|
133 | 150 | }
|
134 | 151 |
|
|
0 commit comments