Repository navigation
HADOOP-20010. Use ExitUtil instead of Runtime.exit in ExpiredTokenRemover. - #8805
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@slfan1989 @zhtttylz would you have time to review this PR? This goes also with related PR #8806 |
smengcl
left a comment
There was a problem hiding this comment.
Thanks @joseluisll for the patch. Claude generated some review comments. ptal
d553f0b to
08364ed
Compare
smengcl
left a comment
There was a problem hiding this comment.
Thanks @joseluisll . lgtm
This comment was marked as outdated.
This comment was marked as outdated.
…over. The expired token remover thread called Runtime.getRuntime().exit(-1) on any unexpected Throwable. Tests could not intercept it, so a token manager leaked past tearDown() killed the surefire fork when its ZooKeeper server went away. Use ExitUtil.terminate() so tests can disable System.exit, and don't terminate when the exception arrives after stopThreads() has cleared the running flag and interrupted the thread. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…enRemover tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Let Errors raised while stopping still terminate, and log the exception at INFO without a stack trace on a normal stop. - Always stop the manager and reset the ExitUtil state in testExpiredTokenRemoverFailureWhileStoppingDoesNotTerminate. - Check and reset the ExitUtil state in a finally block in TestZKDelegationTokenSecretManager#tearDown, and use fail(). - Use assertThat(...).hasMessage(...) for the cause message. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
08364ed to
dc7ab3b
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
CI errors are covered by HADOOP-19966: token cache restart race (testNodesLoadedAfterRestart) |
Disable System.exit and check the recorded termination in dedicated @BeforeEach/@AfterEach methods instead of editing setup() and tearDown(), so this change does not overlap HADOOP-19966 (apache#8688), which also edits them. JUnit runs every @AfterEach method even if tearDown() fails, so the ExitUtil state is still always checked and reset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ExitUtil check no longer runs in tearDown(), so wrapping super.tearDown() in try/finally is plain resource cleanup and belongs with the other finally-block fixes in HADOOP-20011. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Pushed two small changes:
I checked this together with #8806 and #8688 (HADOOP-19966). All three |
This comment was marked as outdated.
This comment was marked as outdated.
|
🎊 +1 overall
This message was automatically generated. |
|
@smengcl @slfan1989 This PR is ready for review. |
smengcl
left a comment
There was a problem hiding this comment.
Thanks @joseluisll . lgtm. One optional nit. Pls update PR description to match the code changes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
🎊 +1 overall
This message was automatically generated. |
|
Addresed the review comments, ready to be merged. |
|
Thanks @joseluisll for the patch. |
Description of PR
https://issues.apache.org/jira/browse/HADOOP-20010
AbstractDelegationTokenSecretManager.ExpiredTokenRemover.run()catches everyThrowableand callsRuntime.getRuntime().exit(-1). Tests can't intercept that, and it can also fire while the secret manager is being stopped.ExitUtil.terminate(-1, t)instead ofRuntime.getRuntime().exit(-1), so tests that callExitUtil.disableSystemExit()get anExitExceptioninstead of a dead JVM.stopThreads()clearsrunningand then interrupts the thread. With a ZooKeeper-backed store, the interrupt can surface as aRuntimeException. Ifrunningis already false and the throwable is not anError, it is logged at INFO and the thread returns.Errors (e.g. OOM) still terminate.TestZKDelegationTokenSecretManageradds its own@BeforeEachthat disables system exit and an@AfterEachthat fails the test ifExitUtil.terminatewas called, then resets the recorded exit. They are separate lifecycle methods, so the check runs even whentearDown()fails. Without this, a remover thread from a leaked manager would kill the surefire fork after the ZooKeeperTestingServercloses, and the original failure would be lost. A leaked remover that terminates after the check is reported by the next test.The RBF
TestZKDelegationTokenSecretManagerImpl.tearDown()change (resetting the static curator infinally) is handled separately in HADOOP-20011. SwitchingSecurityUtil.doAsLoginUserOrFataltoExitUtilis tracked in HADOOP-20022.How was this patch tested?
JDK 21, one fresh fork per test class:
mvn -pl hadoop-common-project/hadoop-common test -Dtest=TestDelegationToken,TestZKDelegationTokenSecretManager: 0 failures. This includes two new tests inTestDelegationToken:testExpiredTokenRemoverFailureTerminates: a remover failure while running callsExitUtil.terminate(-1, ...).testExpiredTokenRemoverFailureWhileStoppingDoesNotTerminate: a failure raised whilestopThreads()is interrupting the thread does not.mvn -pl hadoop-hdfs-project/hadoop-hdfs-rbf test -Dtest=TestZKDelegationTokenSecretManagerImpl: 15 tests, 0 failures, with HADOOP-20009 applied.Before HADOOP-20009 was merged, a failing
testNodesLoadedAfterRestartleaked a manager. About 48 s later, its remover hitConnectionLossduring the next test. With this patch that shows up as a test failure. On trunk the same path callsRuntime.exit(-1)and kills the fork.For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?AI Tooling
Contains content generated by Claude Code.
🤖 Generated with Claude Code