Jose Luis López created YARN-12069:
--------------------------------------
Summary: TestFederationInterceptorREST#testReplaceLabelsOnNode is
flaky: subcluster selection can return a subcluster that does not own the node
Key: YARN-12069
URL: https://issues.apache.org/jira/browse/YARN-12069
Project: Hadoop YARN
Issue Type: Bug
Reporter: Jose Luis López
h3. Summary
TestFederationInterceptorREST#testReplaceLabelsOnNode
(hadoop-yarn-server-router) asserts that a replaceLabelsOnNode("node3:3") call
is routed to subCluster#3. In full-class runs the assertion fails
intermittently with a randomly chosen subcluster (subCluster#0, subCluster#2),
while the test passes reliably when run in isolation.
h3. Root cause
Two pieces combine:
# *FederationInterceptorREST#getNodeSubcluster (around line 1009) does not
distinguish "subcluster answered" from "subcluster has no such node".* It calls
getNode(...) for every active subcluster in parallel and then picks the
subcluster with the freshest lastHealthUpdate. The result map carries null
NodeInfo values for subclusters that do not host the node, and the selection
loop treats a null response the same as a missing one:
{code:java}
for (Entry<SubClusterInfo, NodeInfo> entry : results.entrySet()) {
NodeInfo nodeResponse = entry.getValue();
if (nodeInfo == null || (nodeResponse != null &&
nodeInfo.getLastHealthUpdate() < nodeResponse.getLastHealthUpdate())) {
subcluster = entry.getKey();
nodeInfo = nodeResponse;
}
}
{code}
When no subcluster actually reports the node (true owner's answer missing), the
loop keeps re-assigning {{subcluster}} on every null-response entry ({{nodeInfo
== null}} is always true), so the method returns an arbitrary subcluster that
*does not host the node* instead of throwing NotFoundException.
# *MockDefaultRequestInterceptorREST#getNode answers for nodes it does not
own.* It returns a NodeInfo for any nodeId that contains the subcluster id or
contains "test" -- the catch-all makes every mock subcluster claim e.g.
testGetNode, which several other tests rely on. State left behind by earlier
tests in the class (interceptors recreated between tests) can leave the true
owner's answer missing, at which point defect 1 picks a random non-owner.
h3. Reproduction
Observed 2026-11-23, Ubuntu 24.04, OpenJDK 17, Maven 3.9.16, at the YARN-12025
PR head (independent of that PR's changes):
{noformat}
mvn test -am -pl
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router
-Dtest='TestFederationInterceptorREST' -Dsurefire.rerunFailingTestsCount=0
{noformat}
* 3 of 4 full-class runs failed at TestFederationInterceptorREST.java:1886:
** expected: <subCluster#3:Success;> but was: <subCluster#0:Success;>
** expected: <subCluster#3:Success;> but was: <subCluster#2:Success;> (twice)
* The same failure reproduces with the PR changes reverted (verified on the
unmodified PR head).
* {{mvn test -Dtest='TestFederationInterceptorREST#testReplaceLabelsOnNode'}}
alone passes.
h3. Suggested fix
# In FederationInterceptorREST#getNodeSubcluster, only consider entries whose
NodeInfo is non-null, and throw NotFoundException("Cannot find " + nodeId + "
in any subcluster") when none matched.
# Optionally tighten the mock so getNode only answers for the subcluster that
owns the node, and/or have tests restore mock state (isRunning, subcluster
registration) in teardown.
h3. Relationship to YARN-12025
Discovered while verifying PR #8838 (YARN-12025). The flake is *pre-existing on
trunk-side code* and is not caused by that PR; it is filed separately so
YARN-12025 stays review-scoped. CI runs of PRs touching
hadoop-yarn-server-router may trip on this test independently.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]