You are viewing a plain text version of this content. The canonical link for it is here.
Posted to yarn-issues@hadoop.apache.org by "Jose Luis López (Jira)" <ji...@apache.org> on 2026/10/13 16:33:00 UTC

[jira] [Commented] (YARN-12025) YARN Router REST forwarding cannot read JSON responses and ignores its configured Jersey client

    [ https://issues.apache.org/jira/browse/YARN-12025?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18126798#comment-18126798 ] 

Jose Luis López commented on YARN-12025:
----------------------------------------

Attached [^Yarn12025.java], a standalone reproduction on the shipped jars. It forwards {{POST /ws/v1/cluster/apps/new-application}} through {{RouterWebServiceUtil#genericForward}} (as {{DefaultRequestInterceptorREST#createNewApplication}} does) to a stub RM endpoint that answers in the requested media type, then reads the answer as {{FederationInterceptorREST#invokeGetNewApplication}} does:
{noformat}
java -cp "$(yarn classpath)" Yarn12025.java
{noformat}
Output on a build of trunk (86e6c203, YARN-12012) (MessageBodyReader message shortened):
{noformat}
router forward, Accept null             -> RM 200 application/json;charset=utf-8; read: FAILED: MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json;charset=utf-8, type=class ...NewApplication
    the router's own client is closed afterwards: true
router forward, Accept application/json -> RM 200 application/json;charset=utf-8; read: FAILED: MessageBodyProviderNotFoundException: MessageBodyReader not found ...
    the router's own client is closed afterwards: true
router forward, Accept application/xml  -> RM 200 application/xml;charset=utf-8; read: OK, application_1700000000000_0001
    the router's own client is closed afterwards: true
router's configured client, JSON           -> FAILED: MessageBodyProviderNotFoundException: MessageBodyReader not found ...
client with YarnJacksonJaxbJsonProvider    -> OK, application_1700000000000_0001
{noformat}
So both parts of the proposed fix are needed: the client from {{createJerseyClient}} cannot read JSON either, and a client with a JSON provider can. It also shows {{genericForward}} closing the caller's client. The same output comes from the Jetty 12 phase A build (HADOOP-19912), so the migration does not cause it.

> YARN Router REST forwarding cannot read JSON responses and ignores its configured Jersey client
> -----------------------------------------------------------------------------------------------
>
>                 Key: YARN-12025
>                 URL: https://issues.apache.org/jira/browse/YARN-12025
>             Project: Hadoop YARN
>          Issue Type: Bug
>          Components: federation, router, webapp
>    Affects Versions: 3.6.0
>            Reporter: Jose Luis López
>            Priority: Major
>         Attachments: Yarn12025.java
>
>
> *Problem*: requests to the YARN Router's REST API that the Router has to parse fail when the response is JSON. For example {{POST /ws/v1/cluster/apps/new-application}} without an {{Accept}} header (or with {{Accept: application/json}}) answers 503 "No active SubCluster available to submit the request." while the Router logs:
> {noformat}
> ERROR org.apache.hadoop.yarn.server.router.RouterServerUtil: MessageBodyReader not found for media type=application/json;charset=utf-8, type=class org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewApplication, genericType=class org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewApplication.
> org.glassfish.jersey.message.internal.MessageBodyProviderNotFoundException: MessageBodyReader not found for media type=application/json;charset=utf-8, type=class org.apache.hadoop.yarn.server.resourcemanager.webapp.dao.NewApplication, ...
> {noformat}
> Calls that the Router forwards with a DAO return type work, because {{RouterWebServiceUtil.getMediaTypeFromHttpServletRequest}} asks the RM for XML in that case, and JAXB reads XML without extra providers.
> *Cause*: {{RouterWebServiceUtil.invokeRMWebService}}
> * builds a bare client, {{Client client1 = ClientBuilder.newClient();}}, with no JSON provider registered (the Router's own web app registers {{JettisonFeature}} and {{JAXBContextResolver}}, but this client does not), so a JSON entity cannot be read;
> * ignores the {{Client client}} it is given, built by {{createJerseyClient}} with the configured connect and read timeouts ({{yarn.router.webapp.connect-timeout}}, {{yarn.router.webapp.read-timeout}}, YARN-8529); it only closes that client, and never closes {{client1}}. So the timeouts do not apply to forwarded calls, and every forwarded call leaves a client open.
> *To reproduce*: a Router with {{FederationInterceptorREST}} in front of two sub-clusters, then {{curl -X POST 'http://<router>:8089/ws/v1/cluster/apps/new-application?user.name=<user>'}}.
> *Proposed fix*: in {{invokeRMWebService}}, send the request through the {{client}} parameter instead of a new one, and register the JSON support the Router web app uses ({{JettisonFeature}} and the {{JAXBContextResolver}}) in {{createJerseyClient}}. A test in {{TestRouterWebServicesREST}} (which runs real RMs) for {{createNewApplication}} with JSON would cover it.
> Found during the Jetty 12 (EE8) migration testing (HADOOP-19912), by an end-to-end test of a federated cluster built from trunk. The bug is on trunk itself; the migration does not cause it.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: yarn-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: yarn-issues-help@hadoop.apache.org