Skip to content

YARN-12002. Stop the Router delegation token secret manager on service stop. - #8808

Merged
slfan1989 merged 1 commit into
apache:trunkfrom
joseluisll:YARN-12002
Oct 10, 2026
Merged

slfan1989 merged 1 commit into
apache:trunkfrom
joseluisll:YARN-12002

Conversation

@joseluisll

@joseluisll joseluisll commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

This PR replaces #8784 and is identical to it (same commits; only the branch name changed, to YARN-12002).

Description of PR

JIRA: YARN-12002

RouterClientRMService#serviceStart calls routerDTSecretManager.startThreads(), which starts the ExpiredTokenRemover daemon thread of AbstractDelegationTokenSecretManager. serviceStop never called stopThreads(), so the thread outlived the service. It kept calling the FederationStateStoreFacade to roll master keys and remove expired tokens after the Router and everything it owns had stopped. RMSecretManagerService#serviceStop already does this for the ResourceManager; the Router left it out.

serviceStop also threw a NullPointerException when the service was initialized but never started, because userPipelineMap is only created in serviceStart.

Changes:

  • RouterClientRMService#serviceStop: after the RPC server stops, call routerDTSecretManager.stopThreads() if the secret manager is not null.
  • RouterClientRMService#serviceStop: guard userPipelineMap.clear() against null.
  • TestRouterClientRMService: two new tests, testServiceStopStopsDelegationTokenSecretManager and testServiceStopWithoutStart.

This was split out of YARN-11984 (#8681), whose federation mock Router closes the state store after the Router stops and so depends on this thread having stopped. This PR is independent of the other PRs split out of YARN-11984 and can be reviewed and merged on its own.

How was this patch tested?

Ran TestRouterClientRMService on Linux with JDK 21: 6/6 tests pass.

Reverted the fix in RouterClientRMService and kept the new tests. Both new tests fail:

  • testServiceStopStopsDelegationTokenSecretManager: expected: <false> but was: <true>. The secret manager is still running after stop().
  • testServiceStopWithoutStart: NullPointerException on userPipelineMap.clear().

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint
    declared according to the connector-specific documentation? Note: Automated CI
    testing doesn't cover all cases so manual testing with cloud storage is still
    required.
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE, LICENSE-binary, NOTICE-binary files?

Object storage, new dependencies and LICENSE/NOTICE do not apply: this patch touches only the YARN Router and adds no dependencies.

AI Tooling

If an AI tool was used:

Contains content generated by Claude Code.

…e stop.

RouterClientRMService#serviceStart calls routerDTSecretManager.startThreads(),
which spawns AbstractDelegationTokenSecretManager's ExpiredTokenRemover daemon.
serviceStop never called stopThreads(), so that thread outlived the service and
kept reaching the FederationStateStoreFacade to roll master keys and remove
expired tokens - after the Router, and everything it owns, had stopped.

RMSecretManagerService#serviceStop already does this for the ResourceManager's
equivalent; the Router simply omitted it.

serviceStop also no longer throws NullPointerException when the service never
started: userPipelineMap is created in serviceStart, so clear() is now guarded
like the secret manager.

TestRouterClientRMService covers both: stopping a started service stops the
secret manager's threads, and a service that was only initialized stops
cleanly.

Split out of YARN-11984, whose federation mock Router closes the state store
once the Router has stopped and so relies on this thread having stopped.

Contains content generated by Claude Code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 25s 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 29m 16s trunk passed
+1 💚 compile 0m 31s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 0m 30s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 0m 29s trunk passed
+1 💚 mvnsite 0m 32s trunk passed
+1 💚 javadoc 0m 31s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 29s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 0m 47s trunk passed
+1 💚 shadedclient 17m 20s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 16s the patch passed
+1 💚 compile 0m 17s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 0m 17s the patch passed
+1 💚 compile 0m 15s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 0m 15s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 10s the patch passed
+1 💚 mvnsite 0m 17s the patch passed
+1 💚 javadoc 0m 15s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 14s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 0m 40s the patch passed
+1 💚 shadedclient 17m 16s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 7m 7s hadoop-yarn-server-router in the patch passed.
+1 💚 asflicense 0m 21s The patch does not generate ASF License warnings.
79m 41s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8808/1/artifact/out/Dockerfile
GITHUB PR #8808
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 41ac2facbb25 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / f733f46
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8808/1/testReport/
Max. process+thread count 1323 (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-8808/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.

@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

Vote Subsystem Runtime Logfile Comment
+0 🆗 reexec 0m 23s 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 29m 32s trunk passed
+1 💚 compile 0m 30s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 compile 0m 30s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 checkstyle 0m 29s trunk passed
+1 💚 mvnsite 0m 30s trunk passed
+1 💚 javadoc 0m 32s trunk passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 29s trunk passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 0m 47s trunk passed
+1 💚 shadedclient 17m 49s branch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚 mvninstall 0m 16s the patch passed
+1 💚 compile 0m 15s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javac 0m 15s the patch passed
+1 💚 compile 0m 15s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 javac 0m 15s the patch passed
+1 💚 blanks 0m 0s The patch has no blanks issues.
+1 💚 checkstyle 0m 12s the patch passed
+1 💚 mvnsite 0m 17s the patch passed
+1 💚 javadoc 0m 15s the patch passed with JDK Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu
+1 💚 javadoc 0m 16s the patch passed with JDK Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
+1 💚 spotbugs 0m 36s the patch passed
+1 💚 shadedclient 17m 13s patch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚 unit 7m 17s hadoop-yarn-server-router in the patch passed.
+1 💚 asflicense 0m 25s The patch does not generate ASF License warnings.
80m 33s
Subsystem Report/Notes
Docker ClientAPI=1.56 ServerAPI=1.56 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8808/2/artifact/out/Dockerfile
GITHUB PR #8808
Optional Tests dupname asflicense compile javac javadoc mvninstall mvnsite unit shadedclient spotbugs checkstyle codespell detsecrets
uname Linux 3269c9644876 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build tool maven
Personality dev-support/bin/hadoop.sh
git revision trunk / 22c964b
Default Java Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Multi-JDK versions /usr/lib/jvm/java-21-openjdk-amd64:Ubuntu-21.0.12.1+1-1-24.04.4-Ubuntu /usr/lib/jvm/java-17-openjdk-amd64:Ubuntu-17.0.20.1+1-1-24.04-Ubuntu
Test Results https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8808/2/testReport/
Max. process+thread count 1295 (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-8808/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.

@slfan1989 slfan1989 self-assigned this Oct 10, 2026

@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.

LGTM.

The shutdown sequence looks correct, and the null guard handles stopping a service that was initialized but never started. The comment also accurately describes the limitation regarding in-flight RPC handlers.

Build and Yetus are green.

This PR is ready to merge from my side.

@slfan1989
slfan1989 merged commit d07707b into apache:trunk Oct 10, 2026
8 checks passed
@slfan1989

Copy link
Copy Markdown
Contributor

@joseluisll Thanks for the contribution! Merged into trunk.

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