Skip to content

YARN-12069. TestFederationInterceptorREST#testReplaceLabelsOnNode is flaky: subcluster selection can return a subcluster that does not own the node - #9019

Open
joseluisll wants to merge 3 commits into
apache:trunkfrom
joseluisll:YARN-12069-upstream
Open

joseluisll wants to merge 3 commits into
apache:trunkfrom
joseluisll:YARN-12069-upstream

Conversation

@joseluisll

Copy link
Copy Markdown
Contributor

TestFederationInterceptorREST#testReplaceLabelsOnNode fails intermittently in full-class runs with a randomly chosen subcluster (subCluster#0, #1 or #2 instead of #3), while passing in isolation. Two defects in FederationInterceptorREST combine:

  1. getNode(...) fans out to the subclusters with a parallel stream and collects into a plain HashMap via forEach — the consumer runs concurrently on ForkJoinPool threads, and concurrent HashMap.put silently drops entries. When the node owner's answer is dropped, nothing is logged; it is simply gone.
  2. getNodeSubcluster(...) cannot distinguish "subcluster answered: node not here" (null NodeInfo) from a real answer. With the owner's entry missing, the loop returns an arbitrary subcluster that does not host the node instead of throwing NotFoundException.

Changes:

  • getNode: merge the parallel results on the calling thread (as invokeConcurrent already does) and drop null answers at collection time — this also removes a caught NPE + WARN that the public getNode(String) logged for every subcluster that does not host the node.
  • getNodeSubcluster: skip null responses and throw NotFoundException when no subcluster hosts the node, so replaceLabelsOnNode, updateNodeResource and getActivities fail with 404 semantics instead of being forwarded to a non-owner subcluster.
  • replaceLabelsOnNode: resolve the target subcluster once (it ran the node lookup twice, and the two resolutions could disagree).
  • New tests: testGetNodeCollectsAllSubClusterAnswers (36-subcluster fan-out asserting no collected answer is ever lost) and NotFound tests for the three node-scoped calls above.

MockDefaultRequestInterceptorREST is left untouched: its contains("test") catch-all is load-bearing for other tests, and with the collection race fixed the owner's answer can no longer disappear.

Testing: reproduced pre-fix on apache/trunk (full-class runs fail with a random subcluster; an instrumented run showed the owner's entry missing from the collected map, present again 1 ms later in an identical call); with the patch, TestFederationInterceptorREST passes twice consecutively (Tests run: 81, Failures: 0); all 4 new tests fail on the unpatched code (Tests run: 4, Failures: 4) and pass with it.

Found while verifying YARN-12025; the flake is pre-existing on trunk-side code and unrelated to that patch.

…flaky: subcluster selection can return a subcluster that does not own the node. Contributed by José Luis López.

Co-Authored-By: Claude <noreply@anthropic.com>
@joseluisll
joseluisll marked this pull request as ready for review November 23, 2026 13:17

@slfan1989 slfan1989 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we add a case where one subcluster lookup fails and the others report that the node is absent? Since both outcomes are discarded here, the Router returns 404 even when it couldn't check the subcluster that owns the node.

… in the node fan-out.

A subcluster whose node lookup fails (unreachable or erroring RM) used to
collapse with a subcluster that answered 'node absent', so the Router
returned 404 even when it had not checked the subcluster owning the node
(review of YARN-12069). getNode(Collection, String) now reports answers
and failed lookups separately: getNodeSubcluster and getNode(String)
throw NotFoundException only when every subcluster answered, and a
YarnRuntimeException (5xx semantics) when the fan-out is indeterminate.
New test covers the mixed case: one subcluster fails, the others report
the node absent.

Contributed by José Luis López.
@joseluisll

Copy link
Copy Markdown
Contributor Author

Good catch — agreed. A subcluster whose lookup fails was collapsed with one that answered "node absent", so the Router returned 404 even when the subcluster owning the node was never checked.

I've fixed getNode to keep answers and failed lookups separate: NotFoundException only when every subcluster answered; a YarnRuntimeException (503) when at least one lookup failed and no subcluster hosts the node — an owner found despite an unrelated failure still resolves normally. Added testReplaceLabelsOnNodePartialFailure for the mixed case you describe. TestFederationInterceptorREST passes 82/82.

@joseluisll
joseluisll requested a review from slfan1989 November 23, 2026 15:17
@hadoop-yetus

Copy link
Copy Markdown

💔 -1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 8m 20s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 1 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 32m 20s trunk passed
+1 💚 compile 0m 27s trunk passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 compile 0m 26s trunk passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 checkstyle 0m 25s trunk passed
+1 💚 mvnsite 0m 28s trunk passed
+1 💚 javadoc 0m 29s trunk passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javadoc 0m 25s trunk passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 spotbugs 0m 43s trunk passed
+1 💚 shadedclient 20m 42s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 17s the patch passed
+1 💚 compile 0m 15s the patch passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javac 0m 15s the patch passed
+1 💚 compile 0m 15s the patch passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 javac 0m 15s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
-0 ⚠️ checkstyle 0m 11s /results-checkstyle-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-router.txt hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router: The patch generated 1 new + 0 unchanged - 0 fixed = 1 total (was 0)
+1 💚 mvnsite 0m 16s the patch passed
+1 💚 javadoc 0m 12s the patch passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javadoc 0m 13s the patch passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 spotbugs 0m 38s the patch passed
+1 💚 shadedclient 18m 55s patch has no errors when building and testing our client artifacts.
_ Other Tests _
-1 ❌ unit 8m 56s /patch-unit-hadoop-yarn-project_hadoop-yarn_hadoop-yarn-server_hadoop-yarn-server-router.txt hadoop-yarn-server-router in the patch passed.
+1 💚 asflicense 0m 22s The patch does not generate ASF License warnings.
97m 15s
Reason Tests
Failed junit tests hadoop.yarn.server.router.webapp.TestFederationInterceptorRESTRetry
Subsystem Report/Notes
Docker ClientAPI=1.57 ServerAPI=1.57 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/1/artifact/out/Dockerfile
GITHUB PR #9019
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 4b8a424cffcc 5.15.0-204-generic #214-Ubuntu SMP Fri Nov 6 00:52:52 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / bd2f868
Default Java Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/1/testReport/
Max. process+thread count 1260 (vs. ulimit of 10000)
modules C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/1/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

…etry and drop unused import.

getNode(String) now reports a YarnRuntimeException instead of a 404 when
subcluster lookups fail, because the subcluster owning the node may not
have been checked. testGetNodeOneBadSC and testGetNodeTwoBadSCs still
expected NotFoundException with only failing subclusters; they now assert
the indeterminate-lookup error and the ids of the failed subclusters,
consistent with testGetNodesOneBadSC. Also remove the commons-lang3 Pair
import left unused by the node fan-out rewrite (checkstyle UnusedImports).

Contributed by José Luis López.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018ArokScc4zSVGdkpfE16M9
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 7m 7s Docker mode activated.
_ Prechecks _
+1 💚 dupname 0m 0s No case conflicting files found.
+0 🆗 codespell 0m 0s codespell was not available.
+0 🆗 detsecrets 0m 0s detect-secrets was not available.
+1 💚 @author 0m 0s The patch does not contain any @author tags.
+1 💚 test4tests 0m 0s The patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+1 💚 mvninstall 31m 22s trunk passed
+1 💚 compile 0m 26s trunk passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 compile 0m 28s trunk passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 checkstyle 0m 26s trunk passed
+1 💚 mvnsite 0m 29s trunk passed
+1 💚 javadoc 0m 30s trunk passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javadoc 0m 28s trunk passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 spotbugs 0m 41s trunk passed
+1 💚 shadedclient 17m 16s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 20s the patch passed
+1 💚 compile 0m 19s the patch passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javac 0m 19s the patch passed
+1 💚 compile 0m 19s the patch passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 javac 0m 19s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 15s the patch passed
+1 💚 mvnsite 0m 20s the patch passed
+1 💚 javadoc 0m 18s the patch passed with JDK Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu
+1 💚 javadoc 0m 18s the patch passed with JDK Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
+1 💚 spotbugs 0m 43s the patch passed
+1 💚 shadedclient 17m 30s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 9m 3s hadoop-yarn-server-router in the patch passed.
+1 💚 asflicense 0m 24s The patch does not generate ASF License warnings.
91m 7s
Subsystem Report/Notes
Docker ClientAPI=1.57 ServerAPI=1.57 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/2/artifact/out/Dockerfile
GITHUB PR #9019
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 23f8a598fe69 5.15.0-204-generic #214-Ubuntu SMP Fri Nov 6 00:52:52 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 741f101
Default Java Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.13.1+2-1-24.04.1-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.21.1+2-1-24.04.1-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/2/testReport/
Max. process+thread count 1293 (vs. ulimit of 10000)
modules C: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router U: hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-router
Console output https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-9019/2/console
versions git=2.43.0 maven=3.9.15 spotbugs=4.9.7
Powered by Apache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants