diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java index 44ed223..0df41af 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-common/src/main/java/org/apache/hadoop/yarn/server/webapp/AppBlock.java @@ -79,9 +79,20 @@ protected AppBlock(ApplicationBaseProtocol appBaseProt, ViewContext ctx, protected void render(Block html) { String webUiType = $(WEB_UI_TYPE); String aid = $(APPLICATION_ID); + if (aid.isEmpty()) { puts("Bad request: requires Application ID"); return; + } else if (aid.endsWith("R")) { + aid = aid.substring(0, aid.length() - 1); + html.p()._("The application master for " + aid + " redirected the " + + "resource manager's web proxy's request back to the web proxy. The " + + "typical cause for this error is a network misconfiguration that " + + "causes the resource manager's web proxy host to resolve to an " + + "unexpected IP address on the application master host. Please " + + "contact your cluster administrator to resolve the issue.")._(); + + return; } try { diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java index 0c5516a..4c0d77f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-resourcemanager/src/main/java/org/apache/hadoop/yarn/server/resourcemanager/webapp/AppPage.java @@ -33,10 +33,15 @@ protected void preHead(Page.HTML<_> html) { commonPreHead(html); String appId = $(YarnWebParams.APPLICATION_ID); + + if (appId.endsWith("R")) { + appId = appId.substring(0, appId.length() - 1); + } + set( - TITLE, - appId.isEmpty() ? "Bad request: missing application ID" : join( - "Application ", $(YarnWebParams.APPLICATION_ID))); + TITLE, appId.isEmpty() ? + "Bad request: missing application ID" : + join("Application ", appId)); set(DATATABLES_ID, "attempts ResourceRequests"); set(initID(DATATABLES, "attempts"), WebPageUtils.attemptsTableInit()); diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java index 0e988b8..9a02e35 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-web-proxy/src/main/java/org/apache/hadoop/yarn/server/webproxy/WebAppProxyServlet.java @@ -44,6 +44,7 @@ import javax.ws.rs.core.UriBuilder; import org.apache.hadoop.io.IOUtils; +import org.apache.hadoop.net.NetUtils; import org.apache.hadoop.yarn.api.records.ApplicationId; import org.apache.hadoop.yarn.api.records.ApplicationReport; import org.apache.hadoop.yarn.conf.YarnConfiguration; @@ -334,7 +335,23 @@ private void methodAction(final HttpServletRequest req, notFound(resp, appId + " appears to be formatted incorrectly."); return; } - + + // Prevent the proxy from trying to call itself. When that happens, it + // gets into an endless loop and consumes all available handler threads + // until the application completes. + if (NetUtils.getLocalInetAddress(req.getRemoteHost()) != null) { + LOG.error("The AM's web app redirected the RM web proxy's request back " + + "to the web proxy. The typical cause is that the AM is resolving " + + "the RM's address as something other than what it expects. Check " + + "your network configuration and the value of the " + + "yarn.web-proxy.address property. Once the host resolution issue " + + "has been resolved, you will likely need to delete the " + + "misbehaving application, " + id); + resp.sendRedirect("/cluster/app/" + id + "R"); + + return; + } + if(securityEnabled) { String cookieName = getCheckCookieName(id); Cookie[] cookies = req.getCookies();